Deep neural network architecture using piecewise linear approximation

ABSTRACT

A log circuit for piecewise linear approximation is disclosed. The log circuit identifies an input associated with a logarithm operation to be performed using piecewise linear approximation. The log circuit then identifies a range that the input falls within from various ranges associated with piecewise linear approximation (PLA) equations for the logarithm operation, where the identified range corresponds to one of the PLA equations. The log circuit computes a result of the corresponding PLA equation based on the respective operands of the equation. The log circuit then returns an output associated with the logarithm operation, which is based at least partially on the result of the PLA equation.

FIELD OF THE SPECIFICATION

This disclosure relates in general to the field of computer architectureand design, and more particularly, though not exclusively, to aprocessing architecture for deep neural networks (DNNs).

BACKGROUND

Due to the continuously increasing number of deep learning applicationsthat are being developed for many different use cases, there is a strongdemand for specialized hardware designed for deep neural networks(DNNs). For example, DNNs typically require a substantial amount ofreal-time processing, which often involves multiple layers of complexoperations on floating-point numbers, such as convolution layers,pooling layers, fully connected layers, and so forth. Existing hardwaresolutions for DNNs suffer from various limitations, however, includingheavy power consumption, high latency, significant silicon arearequirements, and so forth.

BRIEF DESCRIPTION OF THE DRAWINGS

The present disclosure is best understood from the following detaileddescription when read with the accompanying figures. It is emphasizedthat, in accordance with the standard practice in the industry, variousfeatures are not necessarily drawn to scale, and are used forillustration purposes only. Where a scale is shown, explicitly orimplicitly, it provides only one illustrative example. In otherembodiments, the dimensions of the various features may be arbitrarilyincreased or reduced for clarity of discussion.

FIG. 1 illustrates an example embodiment of a deep neural network (DNN)implemented using log and antilog piecewise linear approximationcircuits.

FIGS. 2A-B illustrate an example embodiment of a unified activationfunction circuit for deep neural networks (DNNs).

FIGS. 3A-E illustrate example activation functions for a unifiedactivation function circuit.

FIG. 4 illustrates an example embodiment of a unified activationfunction circuit implemented using modified activation functionequations with base 2 exponent terms.

FIGS. 5A-C illustrate an example embodiment of a log circuit implementedusing piecewise linear approximation.

FIGS. 6A-C illustrate example embodiments of an antilog circuitimplemented using piecewise linear approximation.

FIG. 7 illustrates an example embodiment of an exponent circuitimplemented using piecewise linear approximation.

FIG. 8 illustrates a flowchart for an example processing architectureused to implement artificial neural networks.

FIGS. 9A-B illustrate the scalability of example processingarchitectures for artificial neural networks with respect to thesupported number of parallel operations.

FIGS. 10A-E illustrate various performance aspects of example processingarchitectures for artificial neural networks.

FIGS. 11A-C illustrate examples of DNNs implemented using traditionalactivation functions versus modified activation functions with base 2exponent terms.

FIGS. 12A-B and 13 illustrate various performance aspects of DNNsimplemented using traditional activation functions versus modifiedactivation functions.

FIGS. 14A-B, 15, 16, 17, and 18 illustrate example implementations ofcomputer architectures that can be used in accordance with embodimentsdisclosed herein.

EMBODIMENTS OF THE DISCLOSURE

The following disclosure provides many different embodiments, orexamples, for implementing different features of the present disclosure.Specific examples of components and arrangements are described below tosimplify the present disclosure. These are, of course, merely examplesand are not intended to be limiting. Further, the present disclosure mayrepeat reference numerals and/or letters in the various examples. Thisrepetition is for the purpose of simplicity and clarity and does not initself dictate a relationship between the various embodiments and/orconfigurations discussed. Different embodiments may have differentadvantages, and no particular advantage is necessarily required of anyembodiment.

Deep Neural Network (DNN) Inference Using Log/Antilog Piecewise LinearApproximation Circuits

Due to the continuously increasing number of artificial intelligenceapplications that rely on machine learning (e.g., deep learning), thereis a strong demand for specialized hardware that is designed forimplementing artificial neural networks (e.g., deep neural networks,convolutional neural networks, feedforward neural networks, recurrentneural networks, and so forth). Low-power, low-area, and high-speedhardware is ideal for deep learning applications.

In particular, artificial neural networks, such as deep neural networks(DNNs), are implemented using multiple layers of processing nodes or“neurons,” such as convolution layers, pooling layers, fully connectedlayers, and so forth. The nodes in each layer perform computations on acollection of inputs and associated weights (typically represented asvectors) to generate outputs, which are then used as inputs to the nodesin the next layer. The computations performed by nodes in each layertypically involve transformations of the inputs based on the associatedweights, along with activation functions that are used to determinewhether each node should be “activated.” Further, the layers aretypically repeated in this manner based on the requirements of aparticular application in order to reach the global minima.

Moreover, state-of-the-art DNNs are typically implemented usingoperations on numeric values that are represented using single-precision(32-bit) floating-point format. DNN inference generally requires asignificant volume of real-time processing on these floating-pointnumbers, as it involves multiple layers of complex operations, such asconvolution layers, pooling layers, fully connected layers, and soforth. Further, because these complex operations often involvemultiplications, floating-point multipliers are one of the keycomponents in existing DNN solutions. Floating-point multipliers,however, are extremely costly in terms of power consumption, siliconarea, and latency. Further, while lookup tables (LUTs) may be used tosimplify DNN operations in some cases, LUTs similarly require costlysilicon area.

Accordingly, in some cases, DNN optimization techniques may be leveragedin order to improve performance and/or reduce the requisite silicon areaof hardware used for implementing DNNs and other types of artificialneural networks. These DNN optimization techniques, however, typicallyfocus on reducing the cost of operations by reducing the overallprecision and/or reducing the number of underlying operations (e.g.,limiting the number of convolution layers, pooling layers, and soforth). In some embodiments, for example, hardware used for implementingDNNs may be designed to operate on floating-point representations thathave fewer bits and thus provide less precision (e.g., from 8-bitquantized floating-point to 16-bit fixed-point representations). The useof lower-precision floating-point representations, however, results inan unacceptable accuracy loss in some cases, particularly for largerdatasets. Moreover, DNN optimization techniques that reduce the numberof underlying operations or layers may have adverse effects, such aspoor convergence time for reaching the global minima during DNNtraining. Further, because these various optimizations still requirefloating-point multipliers, they still suffer from the power, area, andperformance limitations of multiplier circuits.

In some cases, DNNs may be implemented using circuitry that performslogarithm, antilogarithm, and/or exponent calculations using lookuptables (LUTs) in order to mitigate the requirements of multipliercircuitry. In some embodiments, for example, the parabolic curve of alog, antilog, and/or exponent operation may be divided into multiplesegments, a curve fitting algorithm may be used to pre-compute thevalues of the respective coefficients, and the pre-computed coefficientsmay then be stored in a lookup table implemented using a memorycomponent (e.g., ROM). In this manner, in order to compute ax²+bx+c forany point on the curve, the values of coefficients a, b, and c are firstfetched from the lookup table, and the result is then calculated usingmultipliers and adders. This approach requires significant silicon areafor the associated LUTs and multipliers, however, and it may alsoconsume multiple clock cycles (e.g., 5-8 clock cycles) in order tocompute the above equation.

Accordingly, this disclosure describes various embodiments of hardwarethat can perform DNN computations efficiently without depending onlookup tables and/or multipliers. Example embodiments that may be usedto implement the features and functionality of this disclosure will nowbe described with more particular reference to the attached FIGURES.

FIG. 1 illustrates an example embodiment of a deep neural network (DNN)100 implemented using log and antilog piecewise linear approximationcircuits. In the illustrated example, DNN 100 is implemented usingmultiple layers 106 a-e, including a first convolution layer 106 a, amax pooling layer 106 b, a second convolution layer 106 c, a thirdconvolution layer 106 d, and a fully connected layer 106 e. Moreover,DNN 100 is implemented using a multiplier-free neural networkmicroarchitecture, which uses log and antilog circuits 110, 120 ratherthan multiplier circuits in order to perform computations for therespective DNN layers 106 a-e. In particular, the log and antilogcircuits 110, 120 perform log base 2 (log₂) and antilog base 2(antilog₂) calculations, which can be leveraged to convert themultiplication operations that are typically required in certain DNNlayers 106 into addition. Further, the log and antilog circuits 110, 120use piecewise linear approximation to perform the log₂ and antilog₂calculations, which enables each calculation to be performed in a singleclock cycle and without the use of lookup tables or multipliers. In thismanner, the illustrated embodiment reduces DNN processing latency whilealso eliminating the need for multiplier circuitry and lookup tables,which significantly reduces the requisite silicon area of the hardware.Example implementations of the log 110 and antilog 120 circuits arefurther illustrated and described in connection with FIGS. 5A-C and6A-C.

As an example, with respect to the convolution layer(s) of a DNN (e.g.,layers 106 a,c,d of DNN 100), convolution can generally be representedby the following equation (where f(n) and g(n) are floating-pointvectors):

${\left( {f*g} \right)(n)} = {\sum\limits_{k = {- \inf}}^{+ \inf}\;{{f(k)}{g\left( {n - k} \right)}}}$In this equation, each summation term is computed using multiplication.If log₂ is taken on both sides of the equation, however, the equationbecomes:log₂(ƒ*g)(n)=log₂Σ_(k=−inf) ^(+inf)(k)g(n−k)Further, if the left side of the equation is defined as y(n), meaninglog₂(ƒ*g)(n)=y(n), the equation then becomes:

${y(n)} = {\log_{2}{\sum\limits_{k = {- \inf}}^{+ \inf}\;{{f(k)}{g\left( {n - k} \right)}}}}$The above equation no longer serves the purpose of convolution, however,as convolution cannot be performed by accumulating the results of log₂calculations. Accordingly, antilog₂ must be taken on each summation termbefore it is accumulated (e.g., in order to convert each summation termfrom the log₂ domain back to the original domain):

${y(n)} = {\sum\limits_{k = {- \inf}}^{+ \inf}\; 2^{{\log_{2}{({f{(k)}})}} + {\log_{2}{({g{({n - k})}})}}}}$In this alternative equation for convolution, each summation term is nowcomputed using addition. Thus, while the original convolution equationshown above requires multiplication to compute each summation term, thisalternative convolution equation requires addition rather thanmultiplication. Accordingly, this alternative equation essentiallyleverages log₂ (and antilog₂) operations to convert the multiplicationsrequired by the original convolution equation into additions. Forexample, since f(n) and g(n) in the convolution equation arefloating-point numbers (e.g., IEEE-754 single-precision floating-pointnumbers), log₂ and antilog₂ are taken on the mantissa bits, while theexponent and sign bits are handled separately, as discussed further inconnection with FIGS. 5A-C and 6A-C. In this manner, the log and antilogcircuitry 110, 120 can be used to perform convolution using thisalternative equation instead of the original equation in order to avoidcomplex floating-point multiplication operations.

As another example, a fully connected layer (e.g., layer 106 e of DNN100) is the last layer of a DNN and is responsible for performing thefinal reasoning and decision making. In general, a fully connected layeris similar to a convolution layer, but typically involvessingle-dimension vectors. Accordingly, a fully connected layer canleverage log₂ calculations in a similar manner as a convolution layer inorder to convert multiplication operations into addition. However,because a fully connected layer is the last layer of a DNN, the finaloutputs should be in the normal domain rather than the log₂ domain.

To illustrate, a fully connected layer can generally be representedusing the following equation:

${\left( {f_{fcl}*g_{fcl}} \right)(n)} = {\sum\limits_{k = {- \inf}}^{+ \inf}\;{{f(k)}_{fcl}{g\left( {n - k} \right)}_{fcl}}}$As with convolution, log₂ can be taken on both sides of the equation inorder to convert the multiplication into addition in the summationterms. After taking log₂ on both sides of the equation, and furthersubstituting the left side of the equation with y_(fcl), the resultingequation becomes:

$y_{fcl} = {{\sum\limits_{k = {- \inf}}^{+ \inf}\;{\log_{2}\left( {f(k)} \right)}_{fcl}} + {\log_{2}\left( {g\left( {n - k} \right)} \right)}_{fcl}}$Antilog₂ can then be taken on the respective summation terms before theyare accumulated, thus converting them from the log₂ domain back to thenormal domain:

$y_{fcl} = {\sum\limits_{k = {- \inf}}^{+ \inf}\; 2^{{\log_{2}{({f{(k)}})}}_{fcl} + \log_{2{({g{({n - k})}})}_{fcl}}}}$In this manner, the final outputs of the fully connected layer are inthe normal domain rather than the log₂ domain. Further, themultiplications required by the original equation have been convertedinto additions in this alternative equation.

In the illustrated embodiment, for example, DNN 100 is implemented usingmultiple layers 106 a-e, including a first convolution layer 106 a, amax pooling layer 106 b, a second convolution layer 106 c, a thirdconvolution layer 106 d, and a fully connected layer 106 e. Each layer106 a-e performs computations using an input (X) 101 a-e, along with aweight vector (W) 102 a-d in certain layers, and produces acorresponding output (Y) 103 a-f. Moreover, an initial input vector (X)101 a is fed into the first layer 106 a of DNN 100, while each remaininglayer 106 b-e is fed with the output (Y) 103 a-d of the preceding layeras its input (X) 101 b-e.

Further, log and antilog circuits 110, 120 implemented using piecewiselinear approximation are leveraged to perform the computations at eachlayer 106 of DNN 100, thus eliminating the need for multiplier circuitsand lookup tables, while also reducing latency. For example, the logcircuitry 110 performs log₂ calculations in order to convertfloating-point numbers into fixed-point numbers, which enables complexoperations such as floating-point multiplications to be converted intofixed-point additions, and the antilog circuitry 120 performs anitlog₂calculations in order to subsequently convert fixed-point numbers backto floating-point numbers. Moreover, the log and antilog circuits 110,120 use piecewise linear approximation to perform the respective log₂and antilog₂ calculations, which enables each calculation to beperformed in a single clock cycle.

In the illustrated embodiment, for example, log circuitry 110 is used toconvert the original input vector (X) 101 a and each weight vector (W)102 a-d into the log₂ domain before they are fed into DNN 100, whileantilog circuitry 120 is used to convert the final output (Y) 103 f ofthe fully connected layer 106 e back to the normal domain from the log₂domain. Further, additional antilog₂ and log₂ operations (not shown) arealso performed throughout the hidden layers of DNN 100 (e.g., theintermediate layers between the input and output layers) in order toconvert between the log₂ domain and the normal domain, as necessary. Forexample, as explained above, a convolution layer requires each summationterm to be converted back to the normal domain before it is accumulated,and thus an antilog₂ operation must be performed before accumulatingeach summation term. The final output of a hidden layer is subsequentlyconverted back to the log₂ domain before being provided to the nextlayer, however, in order to continue avoiding multiplication operationsin subsequent layers.

For example, the result of each hidden layer node is typically passed toan activation function that determines whether the node should be“activated,” and the output of the activation function is then fed asinput to the next layer. Accordingly, in order to avoid multiplicationoperations in the next layer, log₂ of the activation function of ahidden layer node is supplied to the next layer. For example, after ahidden layer node performs antilog₂ operations for the purpose ofcomputing a convolution component, the result is converted back to thelog 2 domain before being passed to the activation function. In thismanner, the output (Y) computed by each hidden layer node is already inthe log₂ domain when it is provided as input (X) to the next layer.

Accordingly, the illustrated embodiment provides numerous advantages,including low latency, high precision, and reduced power consumptionusing a flexible, low-area hardware design that is highly scalable andportable. For example, in the illustrated embodiment, DNN 100 isimplemented using log and antilog circuits 110, 120 that perform log₂and antilog₂ calculations using piecewise linear approximation, whicheliminates the need for multiplier circuits and lookup tables in thehardware design. In this manner, the illustrated embodimentsignificantly reduces the requisite silicon area (e.g., by eliminatingmultipliers and lookup tables), power consumption, and latency of thehardware, yet still provides high precision. In particular, the proposedmicroarchitecture performs each log₂ and antilog₂ calculation in asingle clock cycle, which decreases the delay through the datapath andthus decreases the overall latency of the hardware.

The proposed microarchitecture is also highly scalable. In particular,the flexible implementation of the proposed microarchitecture allows thehardware to be replicated as needed in order to increase the number ofsupported parallel operations. For example, the proposedmicroarchitecture may be implemented using any number of log and antilogcircuit(s) 110, 120. In this manner, the proposed microarchitecture canbe easily scaled to support the number of parallel operations requiredby a particular application or use case. The precision of the proposedmicroarchitecture can also be scaled based on application requirements.For example, if an application demands greater precision, the number ofsegments in the piecewise linear approximation model used by the log andantilog circuitry 110, 120 can be increased to accommodate the precisionrequirements. In this manner, the proposed microarchitecture is alsohighly portable, as it can be easily ported and/or scaled for anyproduct or form factor, including mobile devices (e.g., handheld orwearable devices), drones, servers, and/or any other artificialintelligence solutions that require DNN operations without anydependencies or modifications.

DNN Activation Function Circuit Using Piecewise Linear Approximation

Due to the continuously increasing number of products designed withartificial intelligence (AI) capabilities, there is a strong demand forspecialized hardware capable of accelerating fundamental AI operations(e.g., neural network activation functions), while also remaininggeneric enough to support a variety of different implementations andassociated algorithms, particularly for resource-constrained formfactors (e.g., small, low-power edge devices).

In particular, the rising popularity of AI solutions that rely onmachine learning (e.g., deep learning) has led to a demand for hardwareacceleration designed for artificial neural networks (e.g., deep neuralnetworks, convolutional neural networks, feedforward neural networks,recurrent neural networks, and so forth). For example, a deep neuralnetwork (DNN) is implemented using multiple layers of “artificialneurons,” which are typically processing nodes that use non-linearactivation functions to determine whether they should each “activate” inresponse to a particular input. An activation function, for example, isa function that typically maps an input to an output using a non-lineartransformation in order to determine whether a particular processingnode or “artificial neuron” should activate. The use of activationfunctions is an important aspect of DNNs, but it can also be verycomputationally-intensive.

There are many different types of activation functions that can be usedin the implementation of a DNN, including Sigmoid, Hyperbolic Tangent(Tan h), Rectified Linear Unit (ReLU), Leaky ReLU, and Swish, amongother examples. The choice of activation function(s) has a significantimpact on the training dynamics and task performance of a DNN. Thus, insome cases, a DNN may be implemented using multiple activation functionswithin a single neural network in order to increase training dynamicsand performance. DNN compute engines may also rely on specializedhardware for implementing these activation functions, which typicallyoccupies a decent amount of area on silicon. For example, hardwaredesigned for state-of-the-art DNNs typically operates onsingle-precision (32-bit) floating-point numbers and uses a lookup table(LUT) approach to implement activation functions. The use of a lookuptable (LUT) approach for activation functions, however, increasessilicon area, power consumption, and latency, which each continue togrow as the number of neurons in a DNN increases. Moreover, because eachactivation function requires its own lookup table, the use of multipleactivation functions in a single DNN increases the requisite number oflookup tables, thus further impacting silicon area, power, and latency.

As an example, using a lookup table approach, the curve of an activationfunction is typically bounded between an interval [−m, m] (where ‘m’ isa real number), and the bounded curve may then be divided into multiplesegments. A curve fitting algorithm may then be used to pre-compute thevalues of the respective coefficients, and the pre-computed coefficientsmay then be stored in a lookup table implemented using a memorycomponent (e.g., ROM). In this manner, in order to compute ax²+bx+c forany point on the curve, the values of coefficients a, b, and c are firstfetched from the lookup table, and the result is then calculated usingmultipliers and adders. This approach requires significant silicon areafor the associated lookup tables and multipliers, however, and it mayalso consume multiple clock cycles (e.g., 5-8 clock cycles) in order tocompute the above equation.

To illustrate, a bounded curve over the interval [−3, 3] that is dividedinto 256 uniform segments with a 64-bit coefficient width (a: 20 bits,b: 20 bits, c: 24 bits) produces 21-bit mantissa precision for IEEE-754single-precision floating-point numbers. In certain embodiments, thisapproach requires a 256×64 ROM and a compute block which respectivelycomprise 41,853 and 5,574 synthesis gates (e.g., NAND equivalent gates).Scaling down this hardware with less precision (e.g., 12-bit or 10-bitprecision) will only save ROM area. In certain embodiments, for example,the estimated silicon area required for the Sigmoid activation functionwith 10-bit precision is 17,120 synthesis gates. Moreover, this areamust be further replicated or instantiated based on the number ofparallel operations that the hardware is required to support.

Thus, existing hardware used to implement DNN activation functions(e.g., hardware implemented using lookup tables) has various drawbacks,including costly silicon area requirements, poor power consumption, andhigh processing latency, among other examples. These drawbacks arefurther magnified as the hardware is scaled, such as by increasing thenumber of artificial neurons, parallel operations, and/or activationfunctions. Further, there are no unified hardware solutions that canimplement multiple activation functions without using separate hardwareblocks and/or lookup tables for each activation function.

Accordingly, this disclosure describes various embodiments of a unifiedhardware solution that supports multiple DNN activation functionswithout using lookup tables, as described further below.

FIGS. 2A-B illustrate an example embodiment of a unified activationfunction (AF) circuit 200 for artificial neural networks (e.g., deepneural networks (DNNs)). In particular, AF circuit 200 provides supportfor multiple DNN activation functions on a single hardware componentwithout depending on lookup tables.

In the illustrated embodiment, for example, AF circuit 200 implementsthe respective activation functions using a novel algorithm thatleverages exponent, log base 2 (log₂), and antilog base 2 (antilog₂)calculations, which are implemented using piecewise linearapproximation, in order to simply the requisite computations for eachactivation function. For example, many activation functions arenon-linear functions that involve complex exponent, division, and/ormultiplication operations, which are typically implemented using costlymultiplier circuitry (e.g., division may be implemented using multipliercircuitry that multiplies the numerator by the inverse of thedenominator). AF circuit 200, however, leverages log₂ and antilog₂calculations in order to eliminate complex division and/ormultiplication operations required by certain activation functions andinstead convert them into subtraction and/or addition. Further, AFcircuit 200 implements exponent, log₂, and antilog₂ calculations usingpiecewise linear approximation in order to further simplify therequisite computations required by activation functions. As a result,log₂ and antilog₂ calculations can be performed in a single clock cycle,while exponent calculations can be performed in two clock cycles. Inthis manner, an activation function can be computed in only five clockcycles, and the underlying computations can easily be pipelined in orderto increase throughput. Accordingly, AF circuit 200 leverages the log₂,antilog₂, and exponent calculations implemented using piecewise linearapproximation to simplify the underlying computations for an activationfunction, which eliminates the need for lookup tables, reduces themultiplier circuitry requirements, and reduces the overall latency of anactivation function. This approach translates directly into significantsavings of silicon area (e.g., due to the elimination of lookup tablesand reduced multiplier circuitry), as it requires a much smaller numberof synthesis gates compared to a typical lookup table approach withsimilar precision.

In the illustrated embodiment, for example, AF circuit 200 includes log,antilog, and exponent blocks 210, 220, 230 for performing the respectivelog₂, antilog₂, and exponent calculations using piecewise linearapproximation. In some embodiments, for example, log, antilog, andexponent blocks 210, 220, 230 may be implemented using 16-segmentpiecewise linear approximation, with 12-bit precision in the mantissa ofan IEEE-754 single-precision floating-point number (i.e., 1 sign bit+8exponent bits+12 mantissa bits=21-bit precision). Exampleimplementations of log, antilog, and exponent blocks 210, 220, 230 arefurther illustrated and described in connection with FIGS. 5A-C, 6A-C,and 7.

AF circuit 200 is a configurable circuit that supports the followingactivation functions: Sigmoid, Hyperbolic Tangent (Tan h), RectifiedLinear Unit (ReLU), Leaky ReLU, and Swish. In other embodiments,however, AF circuit 200 may be designed to support any type or number ofactivation functions. AF circuit 200 can be configured to use any of thesupported activation functions using opcodes. In the illustratedembodiment, for example, AF circuit 200 uses 5-bit opcodes to select thetype of activation function desired by a particular layer or node in theimplementation of a DNN, and the circuit can be re-configured for othertypes of activation functions by simply changing the opcode value. Inthe illustrated embodiment, the five opcode bits 202 a-e are designatedas Tan h 202 a, Sigmoid 202 b, Swish 202 c, ReLU 202 d, and Leaky ReLU202 e, and these respective bit values are set based on the desired typeof activation function. TABLE 1 identifies the hardware configuration ofAF circuit 200 for the various supported activation functions based onthe values of opcode bits 202 a-e.

TABLE 1 Activation function opcodes OPCODE BITS HARDWARE LeakyACTIVATION Tanh Sigmoid Swish ReLU ReLU FUNCTION 1 0 0 0 0 Tanh 0 0 0 01 Leaky ReLU 0 0 0 1 0 ReLU 0 0 1 0 0 Swish 0 1 0 0 0 Sigmoid

The operation of AF circuit 200 varies depending on which activationfunction is selected via opcode bits 202 a-e. Accordingly, thefunctionality of AF circuit 200 is discussed further below in connectionwith FIGS. 3A-E, which illustrate the various activation functions thatare supported by AF circuit 200.

FIG. 3A illustrates a graph of the Sigmoid activation function, which isrepresented mathematically as

$Y = {\frac{1}{1 + e^{- x}}.}$The output of Sigmoid (y-axis) has a range between 0 and 1, and itsshape resembles a smooth step function, which is an importantcharacteristic that makes it useful as a DNN activation function. Inparticular, the function is smooth and continuously differentiable, andthe gradient is very steep between the interval −4 to 4. This means thata small change in X will cause a large change in Y, which is animportant property for back-propagation in DNNs. However, there are alsosome disadvantages to the Sigmoid function. For example, Sigmoid suffersfrom the vanishing gradient problem, as the function is almost flat inthe regions beyond +4 and −4, which results in a very small gradient andmakes it difficult for a DNN to perform course correction. In addition,because the output ranges from 0 to 1, the output is not symmetricaround the origin, which causes the gradient update to go in thepositive direction.

In general, for a given input X represented in single-precisionfloating-point format, the Sigmoid of X, or Sigmoid(X), can be computedusing the following equation:

${f(X)} = \frac{1}{1 + e^{- X}}$Since the above equation requires a costly division operation, however,log₂ and antilog₂ calculations can be leveraged to avoid the division.For example, based on the properties of logarithmic functions, log₂ canbe taken on each side of the equation in order to convert the divisioninto subtraction:

${\log_{2}{f(X)}} = {{\log_{2}\left( \frac{1}{1 + e^{- X}} \right)} = {{\log_{2}(1)} - {\log_{2}\left( {1 + e^{- X}} \right)}}}$In order to solve for ƒ(X), however, antilog₂ must also be taken on eachside of the equation:

${f(X)} = {\frac{1}{1 + e^{- X}} = 2^{{\log_{2}{(1)}} - {\log_{2}{({1 + e^{- X}})}}}}$This alternative equation for the Sigmoid function no longer requiresdivision, as the division has been replaced with subtraction andlog₂/antilog₂ calculations. Further, the exponent, log₂, and antilog₂calculations can be implemented using piecewise linear approximation inorder to further simplify the computations required by this alternativeequation.

Accordingly, turning back to FIGS. 2A-B, AF circuit 200 implements theSigmoid function using the simplified approach described above. Forexample, when AF circuit 200 is configured for the Sigmoid function, theSigmoid opcode bit (reference numeral 202 b) is set to 1 and theremaining opcode bits for the other activation functions (referencenumerals 202 a,c,d,e) are set to 0. In this manner, when an input X(reference numeral 201) is fed into AF circuit 200, it passes throughmux 206 a and demux 207 to bias block 208, which adds a bias to input Xin order to convert it into a negative number (−X). The result −X isthen passed to exponent block 230 in order to compute e^(−X), and thatresult is then passed to adder 212 in order to compute 1+e^(−X). Theresult of 1+e^(−X) passes through mux 206 d to log block 210 b, whichthen computes log₂(+e^(−X)).

Separately, subtractor 211 is supplied with a constant value of 1 as itsfirst operand, while the output of mux 206 e is supplied as its secondoperand. In this case, since the Sigmoid opcode bit 202 b that is fedinto mux 206 e is set to 1, mux 206 e selects a constant value of 0 asits output. Accordingly, constant values of 1 and 0 are supplied as therespective operands to subtractor 211, and thus subtractor 211 computes1−0=1. The resulting value 1 is then passed through mux 206 f to logblock 210 a, which then computes log₂(1) (which is equal to 0).

Thus, log blocks 210 a and 210 b respectively output the results oflog₂(1) and log₂(1+e^(−X)), and those results are then passed asoperands to adder/subtractor 213. In this case, adder/subtractor 213performs subtraction in order to compute log₂(1)−log₂(+e^(−X)), and thatresult is then passed to antilog block 220, which performs an antilog₂calculation: 2^(log) ² ^((1)−log) ² ^((1+e) ^(−X) ⁾. In this manner, theresult computed by antilog block 220 corresponds to the final result ofthe Sigmoid function. For example, based on the properties oflogarithmic functions discussed above:

$2^{{\log_{2}{(1)}} - {\log_{2}{({1 + e^{- X}})}}} = {2^{\log_{2}{(\frac{1}{1 + e^{- X}})}} = {\frac{1}{1 + e^{- X}} = {f(X)}}}$Accordingly, AF circuit 200 outputs the result of antilog block 220 asthe final output Y (reference numeral 203) of the Sigmoid function.

Further, as noted above, the exponent, log₂, and antilog₂ calculationsperformed by the respective exponent, log, and antilog blocks 210-230 ofAF circuit 200 are implemented using piecewise linear approximation inorder to further simplify the computations required by this alternativeequation.

FIG. 3B illustrates a graph of the Hyperbolic Tangent (Tan h) activationfunction, which is represented mathematically as

$Y = {\frac{1 - e^{{- 2}x}}{1 + e^{{- 2}x}}.}$This function has an output that ranges from −1 to 1 and is symmetricaround the origin, and it also has a steeper gradient than the Sigmoidfunction, although it still suffers from the vanishing gradient problem.

In general, for a given input X represented in single-precisionfloating-point format, the hyperbolic tangent of X, or Tan h(X), can becomputed using the following equation:

${f(X)} = \frac{1 - e^{{- 2}X}}{1 + e^{{- 2}X}}$Since the above equation requires a costly division operation, thedivision can be avoided by leveraging log₂ and antilog₂ calculations ina similar manner as described above for the Sigmoid function from FIG.3A. For example, log₂ can be taken on each side of the equation in orderto convert the division into subtraction:

${\log_{2}{f(X)}} = {{\log_{2}\left( \frac{1 - e^{{- 2}X}}{1 + e^{{- 2}X}} \right)} = {{\log_{2}\left( {1 - e^{{- 2}X}} \right)} - {\log_{2}\left( {1 + e^{{- 2}X}} \right)}}}$Further, in order to solve for ƒ(X), antilog₂ can then be taken on eachside of the equation:

${f(X)} = {\frac{1 - e^{{- 2}X}}{1 + e^{{- 2}X}} = 2^{{\log_{2}{({1 - e^{{- 2}X}})}} - {\log_{2}{({1 + e^{{- 2}X}})}}}}$This alternative equation for the Tan h function no longer requiresdivision, as the division has been replaced with subtraction andlog₂/antilog₂ calculations. Further, the exponent, log₂, and antilog₂calculations can be implemented using piecewise linear approximation inorder to further simplify the computations required by this alternativeequation.

Accordingly, turning back to FIGS. 2A-B, AF circuit 200 implements theTan h function using the simplified approach described above. Forexample, when AF circuit 200 is configured for the Tan h function, theTan h opcode bit (reference numeral 202 a) is set to 1 and the remainingopcode bits for the other activation functions (reference numerals 202b,c,d,e) are set to 0. In this manner, when an input X (referencenumeral 201) is fed into AF circuit 200, it initially passes throughshifter 204, which left shifts X by a single bit in order to double itsvalue, thus producing an output of 2X. Moreover, since AF circuit 200 isconfigured for the Tan h function, the output of 2X from shifter 204 isthen passed through mux 206 a and demux 207 to bias block 208. Forexample, since the selection signal of mux 206 a is based on the Tan hopcode bit 202 a, which is set to 1, mux 206 a selects 2X as the outputthat it passes to demux 207. Further, since the selection signal ofdemux 207 is based on the output of an OR gate 205 that is fed with theReLU/Leaky ReLU opcode bits 202 d,e as input, which are both set to 0,demux 207 routes the value of 2X to bias block 208.

Bias block 208 then adds a bias to 2X in order to convert it into anegative number (−2X), and the resulting value of −2X is then passed toexponent block 230, which outputs the value of e^(−2X). The outpute^(−2X) from exponent block 230 is then passed to both subtractor 211(via mux 206 e) and adder 212, and subtractor 211 then computes thevalue of 1−e^(−2X), while adder 212 computes the value of 1+e^(−2X).These outputs from subtractor 211 and adder 212 are respectively passedto log blocks 210 a and 210 b, which respectively compute the values oflog₂(1−e^(−2X)) and log₂(1+e^(−2X)).

The respective outputs from log blocks 210 a and 210 b are then passedas operands to adder/subtractor 213, which performs subtraction in orderto compute log₂(−e^(−2X))−log₂(1+e^(−2X)), and that result is thenpassed to antilog block 220, which performs an antilog₂ calculation:2^(log) ² ^((1−e) ^(−2X) ^()−log) ² ^((1+e) ^(−2X) ⁾. In this manner,the result computed by antilog block 220 corresponds to the final resultof the Tan h function. For example, based on the properties oflogarithmic functions discussed above:

$2^{{\log_{2}{({1 - e^{{- 2}X}})}} - {\log_{2}{({1 + e^{{- 2}X}})}}} = {2^{\log_{2}{(\frac{1 - e^{{- 2}X}}{1 + e^{{- 2}X}})}} = {\frac{1 - e^{{- 2}X}}{1 + e^{{- 2}X}} = {f(X)}}}$Accordingly, AF circuit 200 outputs the result of antilog block 220 asthe final output Y (reference numeral 203) of the Tan h function.

Further, as noted above, the exponent, log₂, and antilog₂ calculationsperformed by the respective exponent, log, and antilog blocks 210-230 ofAF circuit 200 are implemented using piecewise linear approximation inorder to further simplify the computations required by this alternativeequation.

FIG. 3C illustrates a graph of the Rectified Linear Unit (ReLU)activation function, which is represented mathematically as Y=max(0,X).ReLU is a widely used activation function that provides variousadvantages. In particular, ReLU is a non-linear function that avoids thevanishing gradient problem, it is less complex and thus computationallyless expensive than other activation functions, and it has favorableproperties that render DNNs sparse and more efficient (e.g., when itsinput is negative, its output becomes zero, and thus the correspondingneuron does not get activated). On the other hand, weights cannot beupdated during back-propagation when the output of ReLU becomes zero,and ReLU can only be used in the hidden layers of a neural network.

In general, for a given input X represented in single-precisionfloating-point format, the ReLU of X, or ReLU(X), can be computed usingthe following equation:

${f(x)} = \left\{ \begin{matrix}{0,} & {x < 0} \\{x,} & {x \geq 0}\end{matrix} \right.$The above equation is simple and does not require any costlycomputations, and thus its implementation is relatively straightforward,as there is no need to leverage exponent, log₂, or antilog₂calculations.

For example, turning back to FIGS. 2A-B, when AF circuit 200 isconfigured for the ReLU function, the ReLU opcode bit (reference numeral202 d) is set to 1 and the remaining opcode bits for the otheractivation functions (reference numerals 202 a,b,c,e) are set to 0. Inthis manner, when an input X (reference numeral 201) is fed into AFcircuit 200, X initially passes through mux 206 a to demux 207, anddemux 207 then routes X to mux 206 c. Separately, a constant value of 1is also supplied to mux 206 c (via mux 206 b). Further, since theselection signal of mux 206 c is based on the sign bit of x, mux 206 cselects either X or 0 as its output depending on whether X is positiveor negative. Since the output of mux 206 c is the final result of theReLU function, the remaining logic of AF circuit 200 is bypassed and theoutput of mux 206 c is ultimately used as the final output Y (referencenumeral 203) of AF circuit 200 for the ReLU function.

FIG. 3D illustrates a graph of the Leaky Rectified Linear Unit (LeakyReLU) activation function, which is represented mathematically as

$Y = \left\{ {\begin{matrix}{\mspace{11mu}{X,}} & {X \geq 0} \\{{aX},} & {X < 0}\end{matrix},} \right.$where a=0.01. Leaky ReLU is an improved variation of ReLU. For example,with respect to ReLU, when the input is negative, the output andgradient become zero, which creates problems during weight updates inback-propagation. Leaky ReLU addresses this issue when the input isnegative using multiplication of the input by a small linear component(0.01), which prevents neurons from becoming dead and also prevents thegradient from becoming zero.

In general, for a given input X represented in single-precisionfloating-point format, the Leaky ReLU of X, or LeakyReLU(X), can becomputed using the following equation:

${f(x)} = \left\{ \begin{matrix}{0.01,} & {x < 0} \\{\mspace{34mu}{x,}} & {x \geq 0}\end{matrix} \right.$As with ReLU, the equation for Leaky ReLU is simple and does not requireany costly computations, and thus its implementation is relativelystraightforward, as there is no need to leverage exponent, log₂, orantilog₂ calculations.

For example, turning back to FIGS. 2A-B, when AF circuit 200 isconfigured for the Leaky ReLU function, the Leaky ReLU opcode bit(reference numeral 202 e) is set to 1 and the remaining opcode bits forthe other activation functions (reference numerals 202 a,b,c,d) are setto 0. In this manner, when an input X (reference numeral 201) is fedinto AF circuit 200, X initially passes through mux 206 a to demux 207,and demux 207 then routes X to mux 206 c. Separately, a constant valueof 0.01 is also supplied to mux 206 c (via mux 206 b). Further, sincethe selection signal of mux 206 c is based on the sign bit of X, mux 206c selects either X or 0.01 as its output depending on whether X ispositive or negative. Since the output of mux 206 c is the final resultof the Leaky ReLU function, the remaining logic of AF circuit 200 isbypassed and the output of mux 206 c is ultimately used as the finaloutput Y (reference numeral 203) of AF circuit 200 for the Leaky ReLUfunction.

FIG. 3E illustrates a graph of the Swish activation function, which isrepresented mathematically as Y=X*Sigmoid(X). In many cases, Swish hasbeen shown to provide better accuracy than other activation functions(e.g., ReLU).

In general, for a given input X represented in single-precisionfloating-point format, the Swish of X, or Swish(X), can be computedusing the following equation:

${f(X)} = {{X*{Sigmoid}\mspace{11mu}(X)} = {{X*\frac{1}{1 + e^{- X}}} = \frac{X}{1 + e^{- X}}}}$Since the above equation requires a costly division operation, thedivision can be avoided by leveraging log₂ and antilog₂ calculations ina similar manner as described above for the Sigmoid function from FIG.3A. For example, log₂ can be taken on each side of the equation in orderto convert the division into subtraction:

${\log_{2}{f(X)}} = {{\log_{2}\left( \frac{X}{1 + e^{- X}} \right)} = {{\log_{2}(X)} - {\log_{2}\left( {1 + e^{- X}} \right)}}}$Further, in order to solve for ƒ(X), antilog₂ can then be taken on eachside of the equation:

${f(X)} = {\frac{X}{1 + e^{- X}} = 2^{{\log_{2}{(X)}} - {\log_{2}{({1 + e^{- X}})}}}}$This alternative equation for the Swish function no longer requiresdivision, as the division has been replaced with subtraction andlog₂/antilog₂ calculations. Further, the exponent, log₂, and antilog₂calculations can be implemented using piecewise linear approximation inorder to further simplify the computations required by this alternativeequation.

Accordingly, turning back to FIGS. 2A-B, AF circuit 200 implements theSwish function using the simplified approach described above. Forexample, when AF circuit 200 is configured for the Swish function, theSwish opcode bit (reference numeral 202 c) is set to 1 and the remainingopcode bits for the other activation functions (reference numerals 202a,b,d,e) are set to 0. In this manner, when an input X (referencenumeral 201) is fed into AF circuit 200, X passes through mux 206 a todemux 207, and demux 207 then routes X to bias block 208. For example,since the selection signal of mux 206 a is based on the Tan h opcode bit202 a, which is set to 0, mux 206 a selects X as the output that itpasses to demux 207. Further, since the selection signal of demux 207 isbased on the output of an OR gate 205 that is fed with the ReLU/LeakyReLU opcode bits 202 d,e as input, which are both set to 0, demux 207routes the value of X to bias block 208.

Bias block 208 then adds a bias to X in order to convert it into anegative number (−X), and the resulting value −X is then passed toexponent block 230, which outputs the value of e^(−X). The output e^(−X)of exponent block 230 is then passed to adder 212 in order to compute1+e^(−X), and that result then passes through mux 206 d to log block 210b, which then computes log₂(1+e^(−X)). Separately, since the selectionsignal of mux 206 f is based on the Swish opcode bit 202 c, which is setto 1, mux 206 f selects X as the output that is passed to log block 210a, which then computes log₂(X).

The respective outputs from log blocks 210 a and 210 b are then passedas operands to adder/subtractor 213, which performs subtraction in orderto compute log₂(X)−log₂(1+e^(−X)), and that result is then passed toantilog block 220, which performs an antilog₂ calculation: 2^(log) ²^((X)−log) ² ^((1+e) ^(−X) ⁾. In this manner, the result computed byantilog block 220 corresponds to the final result of the Swish function.For example, based on the properties of logarithmic functions discussedabove:

$2^{{\log_{2}{(X)}} - {\log_{2}{({1 + e^{- X}})}}} = {2^{\log_{2}{(\frac{X}{1 + e^{- X}})}} = {\frac{X}{1 + e^{- X}} = {f(X)}}}$Accordingly, AF circuit 200 outputs the result of antilog block 220 asthe final output Y (reference numeral 203) of the Swish function.

Further, as noted above, the exponent, log₂, and antilog₂ calculationsperformed by the respective exponent, log, and antilog blocks 210-230 ofAF circuit 200 are implemented using piecewise linear approximation inorder to further simplify the computations required by this alternativeequation.

Accordingly, the illustrated embodiment of AF circuit 200 of FIGS. 2A-Bprovides numerous advantages, including low latency, high precision, andreduced power consumption using a flexible, low-area hardware designthat supports multiple activation functions and is highly scalable andportable. In particular, AF circuit 200 is a unified solution thatimplements multiple DNN activation functions on a single hardwarecomponent (e.g., rather than using separate hardware components for eachactivation function) without depending on lookup tables. For example, inthe illustrated embodiment, AF circuit 200 is implemented using log,antilog, and exponent circuits 210, 220, 230 that perform log₂,antilog₂, and exponent calculations using piecewise linearapproximation, which eliminates the need for lookup tables in thehardware design and reduces the required multiplier circuitry.

In this manner, the illustrated embodiment significantly reduces therequisite silicon area, power consumption, and latency of the hardware,yet still provides high precision. For example, the elimination oflookup tables and reduced multiplier circuitry translates directly intosignificant savings of silicon area, as a much smaller number ofsynthesis gates is required in comparison to a typical lookup tableapproach with similar precision. Further, log₂ and antilog₂ calculationscan be performed in a single clock cycle, while exponent calculationscan be performed in two clock cycles, which enables an activationfunction to be computed in only five clock cycles. Moreover, theunderlying computations can easily be pipelined in order to increasethroughput.

AF circuit 200 also eliminates the dependency on software forloading/programming lookup tables associated with different activationfunctions, as AF circuit 200 can be configured for different activationfunctions by simply programming the appropriate opcode. Programming anopcode on AF circuit 200 is much simpler and requires fewer clock cyclescompared to programming a lookup table for an activation function.

AF circuit 200 is also highly scalable. In particular, the flexibleimplementation of AF circuit 200 allows the underlying hardware to bereplicated as needed in order to increase the number of supportedparallel operations. In this manner, AF circuit 200 can be easily scaledto support the number of parallel operations required by a particularapplication or use case. The precision of AF circuit 200 can also bescaled based on application requirements. For example, if an applicationdemands greater precision, the number of segments in the piecewiselinear approximation model used by the log, antilog, and exponentcircuitry 210, 220, 230 can be increased to accommodate the precisionrequirements. In this manner, AF circuit 200 is also highly portable, asit can be easily ported and/or scaled for any product or form factor,including mobile devices (e.g., handheld or wearable devices), drones,servers, and/or any other artificial intelligence solutions that requireDNN operations without any dependencies or modifications.

FIG. 4 illustrates an alternative embodiment of a unified activationfunction (AF) circuit 400 for artificial neural networks (e.g., deepneural networks (DNNs)). In the illustrated embodiment, AF circuit 400includes input X 401, activation functions 402 a-d (ReLu, Leaky ReLu,Sigmoid, and Swish, respectively), output Y 403, OR gate 405,multiplexers (muxes) 406 a-e, demultiplexers (demuxes) 407, bias block408, log blocks 410 a-b, subtractor 411, adder 412, adder/subtractor413, and antilog blocks 420 a-b. In particular, AF circuit 400 issimilar to AF circuit 200 from FIGS. 2A-B, except certain activationfunctions are implemented using modified equations that use powers of 2instead of powers of the exponent constant e. To illustrate, theoriginal and modified equations for the Sigmoid, Swish, and HyperbolicTangent activation functions are provided in TABLE 2.

TABLE 2 Modified activation function equations using powers of 2ORIGINAL EQUATION MODIFIED EQUATION SIGMOID${f(X)} = \frac{1}{1 + e^{- X}}$ ${f(X)} = \frac{1}{1 + 2^{- X}}$ SWISH$\quad\begin{matrix}{{f(X)} = {X*{{Sigmoid}(X)}}} \\{= {X*\frac{1}{1 + e^{- X}}}} \\{= \frac{X}{1 + e^{- X}}}\end{matrix}$ $\quad\begin{matrix}{{f(X)} = {X*{{Sigmoid}(X)}}} \\{= {X*\frac{1}{1 + 2^{- X}}}} \\{= \frac{X}{1 + 2^{- X}}}\end{matrix}$ HYPERBOLIC TANGENT${f(X)} = \frac{1 - e^{{- 2}\; X}}{1 + e^{{- 2}\; X}}$${f(X)} = \frac{1 - 2^{{- 2}\; X}}{1 + 2^{{- 2}\; X}}$

As shown in TABLE 2, the exponents of base e in the original equationsare replaced with exponents of base 2 in the modified equations. In thismanner, the important non-linear characteristics of the activationfunctions (e.g., the shape of the curve) are still exhibited by themodified equations, but the underlying activation function hardware canbe implemented much more efficiently. In particular, by replacing theexponents of base e with exponents of base 2, an exponent circuit is nolonger needed by the modified equations, as all of the exponentoperations can now be performed by an antilog circuit. For example,since antilog base 2 of a variable x is equivalent to 2 raised to thepower of x (2^(x)), an antilog circuit that performs antilog base 2operations can be used to compute the powers of base 2 that appear inthe modified activation function equations.

Moreover, performing exponent operations using antilog circuitry ratherthan exponent circuitry reduces both the latency and silicon area of AFcircuit 400. By way of comparison, for example, AF circuit 200 of FIGS.2A-B performs exponent operations using an exponent circuit implementedusing piecewise linear approximation (e.g., the exponent circuit of FIG.7 ), which can perform an exponent operation in two clock cycles andrequires at least one multiplier. AF circuit 400, however, performsexponent operations using an antilog circuit implemented using piecewiselinear approximation (e.g., the antilog circuit of FIGS. 6A-C), whichcan perform an antilog base 2 operation in a single clock cycle andrequires no multipliers. Thus, by replacing the exponent circuitry withantilog circuitry, the overall latency of AF circuit 400 is reduced byone clock cycle, thus enabling an activation function to be computed inonly four clock cycles, compared to five clock cycles for the activationfunction circuit of FIGS. 2A-B. Further, AF circuit 400 no longerrequires any multiplier circuitry, which results in significant siliconarea savings, as the eliminated exponent circuit was the only componentthat required a multiplier. For example, while AF circuit 200 of FIGS.2A-B can be implemented using 8,321 gates, AF circuit 400 can beimplemented using only 7,221 gates.

Moreover, similar to AF circuit 200 of FIGS. 2A-B, AF circuit 400leverages log base 2 (log₂) and antilog base 2 (antilog₂) calculationsusing piecewise linear approximation in order to simply the requisitecomputations for certain activation functions. For example, log₂ andantilog₂ calculations can be used to eliminate the complex divisionand/or multiplication operations required by certain activationfunctions and instead convert them into subtraction and/or addition. Thelog/antilog equations for the modified Sigmoid, Swish, and HyperbolicTangent activation functions from TABLE 2 (which use powers of 2 insteadof e) are provided in TABLE 3. These log/antilog equations for themodified activation functions are derived in a similar manner as thoseof the original activation functions, as described in connection withFIGS. 3A-E.

TABLE 3 Log/antilog versions of modified activation functions (usingpowers of 2) MODIFIED EQUATION LOG/ANTILOG EQUATION SIGMOID${f(X)} = \frac{1}{1 + 2^{- X}}$ 2^(log) ² ^((1)−log) ² ⁽¹⁺² ^(−X) ⁾SWISH $\quad\begin{matrix}{{f(X)} = {X*{{Sigmoid}(X)}}} \\{= {X*\frac{1}{1 + 2^{- X}}}} \\{= \frac{X}{1 + 2^{- X}}}\end{matrix}$ 2^(log) ² ^((X)−log) ² ⁽¹⁺² ^(−X) ⁾ HYPERBOLIC TANGENT${f(X)} = \frac{1 - 2^{{- 2}\; X}}{1 + 2^{{- 2}\; X}}$ 2^(log) ² ⁽¹⁻²^(−2X) ^()−log) ² ⁽¹⁺² ^(−2X) ⁾

In the illustrated embodiment, AF circuit 400 is designed to implementthe Sigmoid, Swish, Tan h, ReLU, and Leaky ReLU activation functions.The Sigmoid, Swish, and Tan h activation functions are implemented usingthe log/antilog equations from TABLE 3, while the ReLU and Leaky ReLUactivation functions are implemented using their original equations fromFIGS. 3C-D, as they do not require any complex division, multiplication,or exponent operations. The operation of AF circuit 400 is otherwisesimilar to AF circuit 200 of FIGS. 2A-B.

Log, Antilog, and Exponent Circuits Implemented Using Piecewise LinearApproximation

FIGS. 5A-C illustrate an example embodiment of a log circuit 500implemented using piecewise linear approximation. In particular, FIG. 5Aillustrates the overall implementation of log circuit 500, while FIGS.5B and 5C illustrate the implementation of certain components of logcircuit 500.

Log circuit 500 performs log calculations using 16-segment piecewiselinear approximation. In this manner, no lookup tables or multipliercircuits are required by log circuit 500, and log calculations can beperformed in a single clock cycle. The equations used by log circuit 500to perform piecewise linear approximation for log calculations are shownbelow in TABLE 4.

TABLE 4 Piecewise linear approximation equations for log₂(1 + m) RANGE #RANGE EQUATION 0 0 ≤ m < 0.0625$m + \frac{m}{4} + \frac{m}{8} + \frac{m}{64}$ 1 0.0625 ≤ m < 0.125$m + \frac{m}{4} + \frac{m}{16} + \frac{1}{256} + \frac{1}{1024}$ 20.125 ≤ m < 0.1875 $m + \frac{m}{4} + \frac{1}{64} - \frac{1}{512}$ 30.1875 ≤ m < 0.25$m + \frac{m}{8} + \frac{m}{16} + \frac{1}{64} + \frac{1}{128}$ 4 0.25 ≤m < 0.3125 $m + \frac{m}{8} + \frac{1}{32} + \frac{1}{128}$ 5 0.3125 ≤ m< 0.375 $m + \frac{m}{16} + \frac{m}{128} + \frac{1}{16}$ 6 0.375 ≤ m <0.4375 $m + \frac{m}{64} + \frac{m}{128} + \frac{1}{16} + \frac{1}{128}$7 0.4375 ≤ m < 0.5 $m - \frac{m}{64} + \frac{1}{16} + \frac{1}{32}$ 80.5 ≤ m < 0.5625 $m - \frac{m}{16} + \frac{m}{128} + \frac{1}{8}$ 90.5625 ≤ m < 0.625$m - \frac{m}{8} + \frac{m}{32} + \frac{1}{8} + \frac{1}{128}$ 10 0.625≤ m < 0.6875 $m - \frac{m}{8} + \frac{1}{8} + \frac{1}{32}$ 11 0.6875 ≤m < 0.75 $m - \frac{m}{8} - \frac{m}{32} + \frac{1}{8} + \frac{1}{16}$12 0.75 ≤ m < 0.8125$m - \frac{m}{4} + \frac{m}{16} + \frac{1}{8} + \frac{1}{16}$ 13 0.8125≤ m < 0.875 $m - \frac{m}{4} + \frac{m}{32} + \frac{1}{4}$ 14 0.875 ≤ m< 0.9375 $m - \frac{m}{4} + \frac{1}{4}$ 15 0.9375 ≤ m < 1$m - \frac{m}{4} - \frac{m}{64} + \frac{1}{4} + \frac{1}{64}$

The equations in TABLE 4 are designed to compute or approximate theresult of log₂(1+m), where m represents the mantissa portion of asingle-precision floating-point input 501. For example, since themantissa m is always bounded between 0 and 1, and since the result oflog₂(0) is undefined, log₂(1+m) is computed instead of log₂(m) in orderto avoid an undefined result when m is 0. Moreover, in order to computelog₂(1+m) using 16-segment piecewise linear approximation, the potentialvalues of m over the interval [0,1] are divided into 16 different rangesor segments, which are designated as ranges 0-15, and separate equationsare defined for each range in order to approximate the result oflog₂(1+m). Further, the respective equations are defined exclusivelyusing addition and/or subtraction on any of the following types ofoperands: m, fractions of m divided by powers of 2, and/or constantvalues. In this manner, the only division required by the equations isexclusively by powers of 2, and thus all division operations can beimplemented using shifters. Further, the loss in precision that resultsfrom the limited “shift-based” division is compensated for through useof the constant values that are added and/or subtracted in certainequations. Accordingly, the respective equations can be implementedexclusively using addition, subtraction, and/or shift operations, thuseliminating the need for complex multiplication/division circuitry.

FIG. 5A illustrates the overall logic of log circuit 500, which isdesigned to implement the equations of TABLE 4. In the illustratedembodiment, log circuit 500 is supplied with a 32-bit single-precisionfloating-point number as input 501 (e.g., supplied via an inputregister), and log circuit 500 computes a corresponding 32-bitfixed-point number as output 503 (e.g., returned via an outputregister), which represents the log₂ value of input 501.

Input 501 includes a sign bit (input[31]), an 8-bit exponent e(input[30:23]), and a 23-bit mantissa m (input[22:0]). Given that thesign of input 501 always matches that of output 503, the sign bit ofinput 501 (input[31]) is fed directly into the corresponding bit ofoutput 503 (output[31]). Moreover, the exponent e of input 501(input[30:23]) is fed into an 8-bit subtractor 502, which subtracts abias of 0x7F from exponent e in order to generate a corresponding 8-bitunbiased exponent. From a mathematical perspective, for example,subtracting the bias from the exponent of a floating-point number alwaysresults in a value equivalent to log₂ of the exponent. Accordingly, theresulting unbiased exponent serves as the integer portion of thefixed-point number represented in output 503 (output[30:23]).

Moreover, the mantissa m of input 501 is used to select thecorresponding range and equation from TABLE 4 that will be used tocompute the fraction field of output 503 (output[22:0]). For example,the four most significant bits of the mantissa m (input[22:19]) aresupplied as input to range selection logic 504, which outputs sixteen1-bit signals (range[0]-range[15]) that correspond to the respectiveranges of m from TABLE 4, such that the signal corresponding to theapplicable range is set to 1 while the remaining signals are set to 0.

Based on the output of range selection logic 504, multiplexers (muxes)508 a-c are then used to select the operands that correspond to theselected equation from TABLE 4, and those operands are then supplied asinput to adder/subtractor 520. In particular, muxes 508 a-c selectbetween various fractions of the mantissa m (e.g., generated using shiftoperations) as well as certain constant values. For example, themantissa m is fed into multiple shifters 506, which each perform a rightshift of m by a certain number of bits in order compute the variousfractions of m over powers of 2 that appear throughout the equations inTABLE 4

$\left( {{e.g.},\frac{m}{4},\frac{m}{8},\frac{m}{16},\frac{m}{32},\frac{m}{64},\frac{m}{128}} \right).$The outputs of these shifters 506 are then fed as inputs to therespective muxes 508 a-c in the manner shown in FIG. 5A. A constantvalue of 0 is additionally supplied as one of the inputs to mux 508 b,as that value is output by mux 508 b for certain equations that do nototherwise require an operand from mux 508 b. Finally, the constant valuerequired by certain equations from TABLE 4 (e.g., ¼, ⅛, 1/16, 1/32,1/64, 1/128, 1/256, 1/512, and/or 1/1024) is generated by constantgeneration logic 510 and is further supplied as input to mux 508 c. Theimplementation of constant generation logic 510 is further illustratedand described below in connection with FIG. 5B.

Each mux 508 a-c then selects an appropriate output that corresponds toone of the operands for the applicable equation from TABLE 4 (e.g.,based on the range selection logic 504), and those outputs are thensupplied as inputs to adder/subtractor 520. Further, the mantissa m isalso supplied directly as another input to adder/subtractor 520, as themantissa is an operand for all of the equations from TABLE 4.

Adder/subtractor 520 then performs the appropriate addition and/orsubtraction operations on the various operands supplied as input, andthe computed result then serves as the 23-bit fraction field of output503 (output [22:0]). The implementation of adder/subtractor 520 isfurther illustrated and described below in connection with FIG. 5C.

FIG. 5B illustrates an example implementation of the constant generationlogic 510 of log circuit 500 from FIG. 5A, which is used to generate theconstant value(s) required by certain equations from TABLE 4. In theillustrated embodiment, constant generation logic 510 includes shifters512 to generate the collection of constant values that appear throughoutthe equations from TABLE 4, multiplexers (muxes) 514 a,b to select thecorresponding constant value(s) for a selected equation from TABLE 4,and an adder 516 to add the selected constant values.

In the illustrated embodiment, a 23-bit constant value of either +1 or−1 is supplied as input to the respective shifters 512 (e.g., dependingon whether each shifter 512 generates a positive or negative fractionconstant). For example, a 23-bit constant value of +1 is supplied asinput to all but one of the shifters which generate positive results,while a 23-bit signed representation of −1 is supplied as input to theonly remaining shifter which generates a negative result (e.g., theshifter that performs a 9-bit right shift to generate − 1/512). Eachshifter 512 then performs a right shift by a certain number of bits inorder to generate the respective fraction constants that appearthroughout the equations from TABLE 4 (e.g., ¼, ⅛, 1/16, 1/32, 1/64,1/128, 1/256, 1/512, 1/1024).

Moreover, since the respective equations from TABLE 4 require eitherzero, one, or two of these fraction constants, the appropriatecombination of fraction constants for a selected equation from TABLE 4is selected using two muxes 514 a,b. In particular, the outputs ofshifters 512 are supplied as inputs to the two muxes 514 a,b in themanner shown in FIG. 5B, and a 23-bit constant value of 0 is alsosupplied as an input to each mux 514 a,b. Each mux 514 a,b then outputseither a particular fraction constant or a value of 0. In this manner,muxes 514,a,b can collectively output zero, one, or two of therespective fraction constants generated by shifters 512, depending onthe particular equation selected from TABLE 4 (e.g., as determined usingthe range selection logic 504 of log circuit 500 from FIG. 5A).

The outputs of muxes 514 a,b are then supplied as inputs to adder 516,which computes their sum. The result from adder 516 then serves as thefinal constant value 511 that is output by the constant generation logic510 of FIG. 5B.

FIG. 5C illustrates an example implementation of the adder/subtractorlogic 520 of log circuit 500 from FIG. 5A, which is used to performaddition and/or subtraction on the operands of a selected equation fromTABLE 4. In the illustrated embodiment, adder/subtractor logic 520includes two adder/subtractors 522 a,b and two OR gates 524 a,b, whichare described further below.

The first adder/subtractor 522 a is supplied with the mantissa m and theoutputs of muxes 508 b and 508 c of log circuit 500 as its operands.Moreover, the particular combination of addition and/or subtractionperformed on these operands by adder/subtractor 522 a is dictated by ORgate 524 a. For example, OR gate 524 a is supplied with the signalscorresponding to ranges 11 and 15 from TABLE 4 as input (e.g., asgenerated by range selection logic 504 of log circuit 500), and theoutput of OR gate 524 a is then fed into adder/subtractor 522 a. In thismanner, when the output of OR gate 524 a is 0, adder/subtractor 522 aadds all operands together, but when the output of OR gate 524 a is 1(e.g., the mantissa m falls within either range 11 or range 15),adder/subtractor 522 a subtracts the operand corresponding to the outputof mux 508 b and adds the remaining operands. In other words, for anyrange of m from TABLE 4 aside from ranges 11 and 15, adder/subtractor522 a outputs the result of m+output of mux 508 b+output of mux 508 c,but for ranges 11 and 15, adder/subtractor 522 a outputs the result ofm−output of mux 508 b+output of mux 508 c.

The second adder/subtractor 522 b is then supplied with the output ofthe first adder/subtractor 522 a and the output of mux 508 a of logcircuit 500 as its respective operands. The output of OR gate 524 bdictates whether adder/subtractor 522 b performs addition or subtractionon these operands. For example, OR gate 524 b is supplied with thesignals corresponding to ranges 7-15 from TABLE 4 as input (e.g., asgenerated by range selection logic 504 of log circuit 500), and theoutput of OR gate 524 b is then fed into adder/subtractor 522 b. In thismanner, when the output of OR gate 524 b is 0, adder/subtractor 522 badds both operands together, but when the output of OR gate 524 b is 1(e.g., the mantissa m falls within any of ranges 7-15), the output ofmux 508 a is subtracted from the output of the first adder/subtractor522 a. In other words, when m falls within ranges 0-6 from TABLE 4,adder/subtractor 522 b computes the output of the first adder/subtractor522 a+the output of mux 508 a, but when m falls within ranges 7-15,adder/subtractor 522 b computes the output of the first adder/subtractor522 a—the output of mux 508 a. The result from the secondadder/subtractor 522 b serves as the final output 521 of theadder/subtractor 520 logic of FIG. 5C.

To illustrate the operation of log circuit 500, the processing flow willbe described for an example input 501. Since the sign and exponentfields of input 501 are always processed in the same manner regardlessof their underlying values, this example focuses on the processingassociated with the mantissa m of input 501. In this example, themantissa m of input 501 (input[22:0]) is assumed to fall within therange 0.125≤m<0.1875, which corresponds to range 2 of TABLE 4.Accordingly, log circuit 500 will execute the corresponding equation forrange 2 from TABLE 4, which is

$m + \frac{m}{4} + \frac{1}{64} - {\frac{1}{512}.}$Log circuit 500 begins by processing the original input 501 in order togenerate and/or obtain the respective operands for the above-referencedequation, and log circuit 500 then supplies those operands toadder/subtractor 520 to compute a result of the equation.

The first operand m, which corresponds to the mantissa field of input501 (input[22:0]), is fed directly from the relevant bitfields of input501 to adder/subtractor logic 520.

The remaining operands for the above-referenced equation are supplied toadder/subtractor logic 520 by muxes 508 a-c. In particular, thecollection of operands that appear throughout the various equations fromTABLE 4 are supplied as inputs to muxes 508 a-c, and muxes 508 a-c thenoutput the particular operands required by the appropriate equation fromTABLE 4. For example, based on the four most significant bits of themantissa m, range selection logic 504 outputs a signal that identifiesthe particular range from TABLE 4 that m falls within, and that rangesignal is then used by muxes 508 a-c to select the appropriate operandsto output. In this example, since m falls within range 2 from TABLE 4,range selection logic 504 outputs a range signal that corresponds torange 2, otherwise denoted as the range[2] signal. Based on the range[2]signal, mux 508 a selects

$\frac{m}{4}\mspace{11mu}\left( {m\operatorname{>>}2} \right)$as its output, mux 508 b selects 0 as its output, and mux 508 c selectsa constant 511 generated by constant generation logic 510 as its output.Turning to constant generation logic 510 of FIG. 5B, for example, therange[2] signal causes muxes 514 a and 514 b to select 1/64 (1>>6) and −1/512 (−1>>9) as their respective outputs, those values are then addedtogether by adder 516, and the resulting constant 511 is output byconstant generation logic 510. Accordingly, mux 508 c selects thisconstant 511 as its output, which has a corresponding value of 1/64−1/512.

In this manner, the following operands are ultimately supplied toadder/subtractor 520:

-   -   m (supplied directly from input 501);

$\frac{m}{4}$

-   -    (supplied by mux 508 a);    -   0 (supplied by mux 508 b); and    -   1/64− 1/512 (supplied by mux 508 c).        The range[2] signal causes adder/subtractor 520 to perform        addition on all of these operands thus computing a result of the        equation

${{m + \frac{m}{4} + 0 + \left( {\frac{1}{64} - \frac{1}{512}} \right)} = {m + \frac{m}{4} + \frac{1}{64} - \frac{1}{512}}},$which is the equation for range 2 from TABLE 4. Accordingly, theresulting value serves as the 23-bit fraction field in the output 503(output [22:0]) generated by log circuit 500.

FIGS. 6A-C illustrate example embodiments of an antilog circuit 600implemented using piecewise linear approximation. In particular, FIGS.6A and 6B illustrate alternative implementations of the overall antilogcircuit 600, while FIG. 6C illustrates the underlying adder/subtractorlogic 620 of antilog circuit 600.

Antilog circuit 600 performs antilog calculations using 16-segmentpiecewise linear approximation. In this manner, no lookup tables ormultiplier circuits are required by antilog circuit 600, and antilogcalculations can be performed in a single clock cycle. The equationsused by antilog circuit 600 to perform piecewise linear approximationfor antilog calculations are shown below in TABLE 5.

TABLE 5 Piecewise linear approximation equations for antilog₂(η) = 2^(η)RANGE # RANGE EQUATION 0 0 ≤ η < 0.0625$\eta - \frac{\eta}{4} - \frac{\eta}{32} + 1$ 1 0.0625 ≤ η < 0.125$\eta - \frac{\eta}{4} - \frac{\eta}{64} + 1 - \frac{1}{512}$ 2 0.125 ≤η < 0.1875 $\eta - \frac{\eta}{4} + \frac{\eta}{32} + 1 - \frac{1}{128}$3 0.1875 ≤ η < 0.25$\eta - \frac{\eta}{8} - \frac{\eta}{16} + 1 - \frac{1}{64}$ 4 0.25 ≤ η< 0.3125$\eta - \frac{\eta}{8} - \frac{\eta}{32} + 1 - \frac{1}{32} + \frac{1}{128}$5 0.3125 ≤ η < 0.375 $\eta - \frac{\eta}{8} + 1 - \frac{1}{32}$ 6 0.375≤ η < 0.4375$\eta - \frac{\eta}{16} - \frac{\eta}{64} + 1 - \frac{1}{32} - \frac{1}{64}$7 0.4375 ≤ η < 0.5$\eta - \frac{\eta}{32} - \frac{\eta}{64} + 1 - \frac{1}{16}$ 8 0.5 ≤ η< 0.5625 $\eta + \frac{\eta}{512} + 1 - \frac{1}{8} + \frac{1}{32}$ 90.5625 ≤ η < 0.625$\eta + \frac{\eta}{16} - \frac{\eta}{64} + 1 - \frac{1}{8} + \frac{1}{128}$10 0.625 ≤ η < 0.6875$\eta + \frac{\eta}{16} + \frac{\eta}{32} + 1 - \frac{1}{8} + \frac{1}{64}$11 0.6875 ≤ η < 0.75$\eta + \frac{\eta}{8} + \frac{\eta}{64} + 1 - \frac{1}{4} + \frac{1}{16}$12 0.75 ≤ η < 0.8125$\eta + \frac{\eta}{8} + \frac{\eta}{16} + 1 - \frac{1}{4} + \frac{1}{32}$13 0.8125 ≤ η < 0.875$\eta + \frac{\eta}{4} - \frac{\eta}{128} + 1 - \frac{1}{4} - \frac{1}{128}$14 0.875 ≤ η < 0.9375$\eta + \frac{\eta}{4} + \frac{\eta}{32} + 1 - \frac{1}{4} - \frac{1}{16}$15 0.9375 ≤ η < 1$\eta + \frac{\eta}{4} + \frac{\eta}{8} + 1 - \frac{1}{4} - \frac{1}{8}$

The equations in TABLE 5 are designed to compute or approximate theresult of antilog₂ of η, which is equivalent to 2 raised to the power ofη, or 2^(n), where η represents the fraction portion of a fixed-pointinput number 601 (input[22:0]). For example, the fixed-point input 601of antilog circuit 600 will typically be derived from intermediate DNNcomputations on the fixed-point outputs 503 of the log circuit(s) 500from FIGS. 5A-C. Moreover, as discussed above, the fraction portion ofthe fixed-point output 503 of a log circuit 500 is computed as log₂(1+m)rather than log₂(m) in order to avoid an undefined result when m=0.Thus, the equations from TABLE 5 for computing antilog₂(η)=2^(n) aredesigned to produce a value that is equivalent to 1+m, as reflected bythe constant value of +1 in each equation.

In order to compute antilog₂(η)=2^(n) using 16-segment piecewise linearapproximation, for example, the potential values of η over the interval[0,1] are divided into 16 different ranges or segments, which aredesignated as ranges 0-15, and separate equations are defined for eachrange in order to approximate the result of antilog₂(η) or 2^(n).Further, the respective equations are defined exclusively using additionand/or subtraction on any of the following types of operands: q,fractions of η divided by powers of 2, and/or constant values. In thismanner, the only division required by the equations is exclusively bypowers of 2, and thus all division operations can be implemented usingshifters. Further, the loss in precision that results from the limited“shift-based” division is compensated for through use of the constantvalues that are added and/or subtracted in certain equations.Accordingly, the respective equations can be implemented exclusivelyusing addition, subtraction, and/or shift operations, thus eliminatingthe need for complex multiplication/division circuitry.

FIG. 6A illustrates the overall logic of antilog circuit 600, which isdesigned to implement the equations of TABLE 5. In the illustratedembodiment, antilog circuit 600 is supplied with a 32-bit fixed-pointnumber as input 601 (e.g., supplied via an input register), and antilogcircuit 600 computes a corresponding 32-bit floating-point number asoutput 603 (e.g., returned via an output register), which represents theantilog₂ result for input 601.

Input 601 includes a sign bit (input[31]), an 8-bit integer(input[30:23]), and a 23-bit fraction (input[22:0]). Given that the signof input 601 always matches that of output 603, the sign bit of input601 (input[31]) is fed directly into the corresponding bit of output 603(output[31]). The integer portion of input 601 (input[30:23]) is fedinto an 8-bit adder 602, which adds back a bias of 0x7F in order togenerate an 8-bit biased exponent that serves as the exponent field ofthe floating-point output 603.

Moreover, the fraction portion of input 601 (input [22:0]), whichcorresponds to the value of η in TABLE 5, is used to select thecorresponding range and equation from TABLE 5 that will be used tocompute the mantissa of the floating-point output 603 (output[22:0]).For example, the four most significant bits of the fraction portion ofinput 601 (input[22:19]) are supplied as input to range selection logic604, which outputs sixteen 1-bit signals (range[0]-range[15]) thatcorrespond to the respective ranges of η from TABLE 5, such that thesignal corresponding to the applicable range is set to 1 while theremaining signals are set to 0. Based on the output of range selectionlogic 604, multiplexers (muxes) 608 a-d are then used to select certainoperands required by the corresponding equation from TABLE 5, such asthe requisite fractions of η and fraction constants.

In particular, muxes 608 a and 608 b are used to select the fractions ofη that are required by the corresponding equation from TABLE 5. Forexample, the value of η (input[22:0]) is fed into a first collection ofshifters 606 a, which each perform a right shift of η by a certainnumber of bits in order compute the various fractions of η over powersof 2 that appear throughout the equations from TABLE 5

$\left( {{e.g.},\frac{\eta}{4},\frac{\eta}{8},\frac{\eta}{16},\frac{\eta}{32},\frac{\eta}{64},\frac{\eta}{128},\frac{\eta}{512}} \right).$inputs to muxes 608 a and 608 b in the manner shown in FIG. 6A. Muxes608 a and 608 b then select the particular fractions of η that arerequired by the corresponding equation from TABLE 5, which is determinedbased on the output of range selection logic 604.

Similarly, muxes 608 c and 608 d are used to select the fractionconstants that are required by the corresponding equation from TABLE 5.For example, a 23-bit constant with a value of 1 is fed into a secondcollection of shifters 606 b, which each perform a right shift by acertain number of bits in order to generate the respective fractionconstants that appear throughout the equations from TABLE 5 (e.g., ¼, ⅛,1/16, 1/32, 1/64, 1/128, 1/512). The outputs of these shifters 606 b arethen fed as inputs to muxes 608 c and 608 d in the manner shown in FIG.6A. Muxes 608 c and 608 d then select the particular constant fractionsthat are required by the corresponding equation from TABLE 5, which isdetermined based on the output of range selection logic 604.

The respective operands selected by muxes 608 a-d for the correspondingequation from TABLE 5 are then supplied as inputs to adder/subtractor620. The value of η (input[22:0]) and a constant value of 1 are alsosupplied as inputs to adder/subtractor 620, as those values are operandsin all of the equations from TABLE 5. Adder/subtractor 620 then performsthe appropriate addition and/or subtraction operations on these operands(e.g., based on the output of range selection logic 604), as required bythe corresponding equation from TABLE 5. The result fromadder/subtractor 620 then serves as the 23-bit mantissa portion of thefloating-point output 603 (output [22:0]) of antilog circuit 600. Theimplementation of adder/subtractor 620 is further illustrated anddescribed below in connection with FIG. 6C.

FIG. 6B illustrates an alternative implementation of an antilog circuit600 implemented using piecewise linear approximation. In particular,while the antilog circuit of FIG. 6A is designed to compute the antilogof a fixed-point number as input, the antilog circuit of FIG. 6B iscapable of computing the antilog of either a fixed-point number or afloating-point number as input. In this manner, the antilog circuit ofFIG. 6B can compute the antilog₂ of either a fixed-point number in thelog₂ domain (e.g., derived from the output of log circuit 500 from FIGS.5A-C) or a floating-point number in its original domain. For example, asdescribed in connection with FIG. 4 , activation function (AF) circuit400 uses antilog circuits for two purposes: (1) converting fixed-pointnumbers in the log₂ domain back to floating-point numbers in theoriginal domain; and (2) computing powers of base 2 raised tofloating-point exponents. Thus, the operands of antilog circuits of AFcircuit 400 include both fixed-point numbers (e.g., for log₂ domainconversions) and floating-point numbers (e.g., for powers of base 2).Accordingly, the antilog circuits of AF circuit 400 can be implementedusing the antilog circuit of FIG. 6B, which is capable of processing aninput represented as either a fixed-point or floating-point number.

The operation of the antilog circuit of FIG. 6B is similar to that ofFIG. 6A with the exception of how it processes the integer or exponentfield of input 601 (input[30:23]), as described further below.

In particular, if input 601 is a fixed-point number, then it willcontain an integer field (input[30:23]), which is supplied as one of theinputs to mux 616. The selection signal of mux 616 is a binary signalthat indicates whether input 601 is a fixed-point number. Accordingly,the selection signal of mux 616 will have a value of 1 when input 601 isa fixed-point number, which causes mux 616 to select the integer portionof input 601 (input[30:23]) as its output, which is then supplied as anoperand to 8-bit adder 602. Adder 602 then adds back a bias of 0x7F tothe integer portion of input 601 (input[30:23]) in order to generate an8-bit biased exponent, which then serves as the exponent portion of thefloating-point output 603.

Alternatively, if input 601 is a floating-point number, then it willcontain an exponent field (input[30:23]). The exponent field(input[30:23]) is supplied to an 8-bit subtractor 612, which subtracts abias of 0x7F in order to generate a corresponding 8-bit unbiasedexponent, which mathematically represents the log₂ value of theexponent. The output of subtractor 612 is then fed into shifter 614,which performs a left shift by 2^(unbiased_exponent) in order to computea corresponding antilog₂ value, which is then supplied as one of theinputs to mux 616. The selection signal of mux 616 will have a value of0 when input 601 is a floating-point number, which causes mux 616 toselect the value from shifter 614 as its output. The output of mux 616is then supplied as an operand to 8-bit adder 602, which adds back abias of 0x7F in order to generate an 8-bit biased exponent, which thenserves as the exponent portion of the floating-point output 603.

FIG. 6C illustrates an example implementation of the adder/subtractorlogic 620 of antilog circuit 600 of FIGS. 6A and 6B, which is used toperform addition and/or subtraction on the operands of a correspondingequation from TABLE 5. In the illustrated embodiment, adder/subtractorlogic 620 includes three adder/subtractors 622 a-c and three OR gates624 a-c, which are described further below.

The first adder/subtractor 622 a is supplied with the following operandsas input: the value of η (input[22:0]), a constant value of 1, and theoutput of mux 608 a. The particular combination of addition and/orsubtraction performed on these operands is dictated by OR gate 624 a,which is fed with the signals for range[0]-range[7] as input. In thismanner, when η falls within ranges 0-7 from TABLE 5, the output of ORgate 624 a will be 1, which causes adder/subtractor 622 a to compute:η+1−output of mux 608 a. Alternatively, when η falls within ranges 8-15,the output of OR gate 624 a will be 0, which causes adder/subtractor 622a to compute: η+1+output of mux 608 a.

The second adder/subtractor 622 b is supplied with the followingoperands as input: the output of mux 608 c and the output of mux 608 d.The particular combination of addition and/or subtraction performed onthese operands is dictated by OR gate 624 b, which is fed with thesignals for range[4], range[8], range[9], range[11], and range[12] asinput. In this manner, when η falls within range 4, 8, 9, 11, or 12 fromTABLE 5, the output of OR gate 624 a will be 1, which causesadder/subtractor 622 b to compute: output of mux 608 c-output of mux 608d. Alternatively, when η falls within any of the remaining ranges fromTABLE 5, the output of OR gate 624 a will be 0, which causesadder/subtractor 622 b to compute: output of mux 608 c+output of mux 608d.

The third adder/subtractor 622 c is supplied with the following operandsas input: the output of adder/subtractor 622 a, the output ofadder/subtractor 622 b, and the output of mux 608 b. The particularcombination of addition and/or subtraction performed on these operandsis dictated by OR gate 624 c, which is fed with the inverse or NOT valueof the signals for range[2], range[10], range[11], range[14], andrange[15] as input. In this manner, when q falls within any range fromTABLE 5 other than range 2, 10, 11, 14, and 15, the output of OR gate624 c will be 1, which causes adder/subtractor 622 c to compute: outputof adder/subtractor 622 a-output of adder/subtractor 622 b-output of mux608 b. Alternatively, when η falls within range 2, 10, 11, 14, or 15from TABLE 5, the output of OR gate 624 c will be 0, which causesadder/subtractor 622 c to compute: output of adder/subtractor 622a-output of adder/subtractor 622 b+output of mux 608 b.

The result from the third adder/subtractor 622 c serves as the finaloutput 621 of the adder/subtractor logic 620 of FIG. 6C.

FIG. 7 illustrates an example embodiment of an exponent circuit 700implemented using piecewise linear approximation. In particular,exponent circuit 700 performs exponent calculations using 16-segmentpiecewise linear approximation. In this manner, exponent circuit 700requires no lookup tables and only one multiplier, and exponentcalculations can be performed in two clock cycles.

The equations used by exponent circuit 700 to perform piecewise linearapproximation for exponent calculations are shown below in TABLE 6.

TABLE 6 Piecewise linear approximation equations for exponent e^(x)RANGE # RANGE EQUATION 0 0 ≤ x < 0.0625 $x + \frac{x}{32} + 1$ 1 0.0625≤ x < 0.125 $x + \frac{x}{64} + \frac{x}{32} + 1 - \frac{1}{256}$ 20.125 ≤ x < 0.1875 $x + \frac{x}{8} + \frac{x}{32} + 1 - \frac{1}{64}$ 30.1875 ≤ x < 0.25 $x + \frac{x}{4} + 1 - \frac{1}{32}$ 4 0.25 ≤ x <0.3125 $x + \frac{x}{4} + \frac{x}{16} + 1 - \frac{1}{16}$ 5 0.3125 ≤ x< 0.375 $x + \frac{x}{4} + \frac{x}{8} + 1 - \frac{1}{16}$ 6 0.375 ≤ x <0.4375 $x + \frac{x}{2} + 1 - \frac{1}{8}$ 7 0.4375 ≤ x < 0.5$x + \frac{x}{2} + \frac{x}{8} + 1 - \frac{1}{8} - \frac{1}{16}$ 8 0.5 ≤x < 0.5625${2x} - \frac{x}{4} - \frac{x}{32} + 1 - \frac{1}{4} + \frac{1}{32}$ 90.5625 ≤ x < 0.625${2x} - \frac{x}{8} - \frac{x}{16} + 1 - \frac{1}{4} - \frac{1}{64}$ 100.625 ≤ x < 0.6875${2x} - \frac{x}{16} - \frac{x}{64} + 1 - \frac{1}{4} - \frac{1}{8}$ 110.6875 ≤ x < 0.75 ${2x} + \frac{x}{16} + 1 - \frac{1}{2} + \frac{1}{16}$12 0.75 ≤ x < 0.8125${2x} + \frac{x}{2} + \frac{x}{16} + 1 - \frac{1}{2} - \frac{1}{32}$ 130.8125 ≤ x < 0.875${2x} + \frac{x}{4} + \frac{x}{16} + \frac{1}{4} + \frac{1}{8}$ 14 0.875≤ x < 0.9375${2x} + \frac{x}{2} - \frac{x}{16} + \frac{1}{4} + \frac{1}{64}$ 150.9375 ≤ x < 1 ${2x} + \frac{x}{2} + \frac{x}{8} + \frac{1}{16}$

The equations in TABLE 6 are designed to compute or approximate theresult of the natural exponential function e^(x), where e represents thenatural exponent constant (e.g., Euler's number) and x represents the23-bit mantissa of a 32-bit floating-point input 701 (input[22:0]). Inorder to compute e^(x) using 16-segment piecewise linear approximation,for example, the potential values of x over the interval [0,1] aredivided into 16 different ranges or segments, which are designated asranges 0-15, and separate equations are defined for each range in orderto approximate the result of e^(x). Further, the respective equationsare defined exclusively using addition and/or subtraction on any of thefollowing types of operands: x, 2x, fractions of x divided by powers of2, and/or constant values. In this manner, the only division required bythe equations is exclusively by powers of 2, and thus all divisionoperations can be implemented using shifters. Further, the loss inprecision that results from the limited “shift-based” division iscompensated for through use of the constant values that are added and/orsubtracted in certain equations. Accordingly, the respective equationsfor e^(x) can be implemented exclusively using addition, subtraction,and/or shift operations.

In order to complete the exponent operation, the resulting value ofe^(x), which represents e raised to the power of the mantissa portion ofinput 701 (input[22:0]), must then be multiplied with the value of eraised to the power of the exponent portion of input 701 (input[30:23]).Accordingly, only one multiplication operation is required for theexponent operation, and thus exponent circuit 700 only requires a singlemultiplier circuit.

The overall logic of exponent circuit 700 is illustrated in FIG. 7 . Inthe illustrated embodiment, exponent circuit 700 is supplied with a32-bit floating-point number as input 701, and exponent circuit 700computes a corresponding 32-bit fixed-point number as output 703, whichcorresponds to the natural exponent constant e raised to the power ofthe floating-point number represented by input 701, or e^(input).

Floating-point input 701 includes a sign bit (input[31]), an 8-bitexponent (input[30:23]), and a 23-bit mantissa (input[22:0]). Given thatthe sign of input 701 always matches that of output 703, the sign bit ofinput 701 (input[31]) is fed directly into the corresponding bit ofoutput 703 (output[31]).

The exponent portion of input 701 (input[30:23]) is fed into an 8-bitsubtractor 702, which subtracts a bias of 0x7F in order to generate an8-bit unbiased exponent. The value of the natural exponent constant eraised to the power of the unbiased exponent, or e^(unbiased_exponent),is then output by mux 710. For example, an 8-bit unbiased exponent has2⁸=256 potential values, which range from −128 to +127. The values of eraised to all 256 potential values of the unbiased exponent (e⁻¹²⁸,e⁻¹²⁷, . . . , e⁰, e¹, . . . , e¹²⁷) are precomputed and fed asconstants inputs into mux 710. The 8-bit unbiased exponent output bysubtractor 702 serves as the selection signal of mux 710, which causesmux 710 to select the precomputed constant input that corresponds toe^(unbiased_exponent). The output of mux 710 (e^(unbased_exponent)) isthen fed into multiplier 712 as one of its operands, as discussedfurther below.

The mantissa portion of input 701 (input [22:0]) is processed accordingto the equations from TABLE 6. For example, exponent circuit 700 isdesigned to compute the natural exponent constant e raised to the powerof the mantissa (input [22:0]), or e^(x), where x represents themantissa (input [22:0]). Moreover, exponent circuit 700 computes e^(x)using piecewise linear approximation based on the equations from TABLE6. In particular, the mantissa portion of input 701 (input [22:0])(which corresponds to the value of x in TABLE 6) is used to select thecorresponding range and equation from TABLE 6 that will be used tocompute the value of e^(x). For example, the four most significant bitsof the mantissa of input 701 (input[22:19]) are supplied as input torange selection logic 704, which outputs sixteen 1-bit signals(range[0]-range[15]) corresponding to the respective ranges of x fromTABLE 6, such that the signal corresponding to the applicable range isset to 1 while the remaining signals are set to 0. Based on the outputof range selection logic 704, multiplexers (muxes) 708 a-d are then usedto select certain operands required by the corresponding equation fromTABLE 6, such as the requisite fractions of x and constant values thatappear in the equation.

For example, muxes 708 a and 708 b are used to select the fractions of xthat are required by the corresponding equation from TABLE 6. Forexample, the value of x (input[22:0]) is fed into a first collection ofshifters 706 a, which each perform a right shift of x by a certainnumber of bits in order compute the various fractions of x over powersof 2 that appear throughout the equations from TABLE 6

$\left( {{e.g.},\frac{x}{2},\frac{x}{4},\frac{x}{8},\frac{x}{16},\frac{x}{32},\frac{x}{64}} \right).$The outputs of these shifters 706 a are then fed as inputs to muxes 708a and 708 b in the manner shown in FIG. 7 . Muxes 708 a and 708 b thenselect the particular fractions of x that are required by thecorresponding equation from TABLE 6, which is determined based on theoutput of range selection logic 704.

Similarly, muxes 708 c and 708 d are used to select the constant valuesthat are required by the corresponding equation from TABLE 6, such asthe fraction constants and/or the constant value of 1 required bycertain equations. For example, a 23-bit constant with a value of 1 isfed into a second collection of shifters 706 b, which each perform aright shift by a certain number of bits in order to generate therespective fraction constants that appear throughout the equations fromTABLE 6 (e.g., ½, ¼, ⅛, 1/16, 1/32, 1/64, 1/256). The outputs of theseshifters 706 b are then fed as inputs to muxes 708 c and 708 d in themanner shown in FIG. 7 . Further, a constant value of 1 (which isrequired by certain equations from TABLE 6) is also supplied as one ofthe inputs to mux 708 d. Muxes 708 c and 708 d then select theparticular combination of constants that are required by thecorresponding equation from TABLE 6, which is determined based on theoutput of range selection logic 704.

The respective operands selected by muxes 708 a-d for the correspondingequation from TABLE 6 are then supplied as inputs to adder/subtractor720. The value of x (input[22:0]) is also supplied to adder/subtractor720 through either one or two of its inputs, depending on whether thecorresponding equation from TABLE 6 requires an operand of x or 2x. Forexample, the value of x is always directly supplied as one of the inputsof adder/subtractor 720, and in some cases, it may also be suppliedthrough mux 709 as another input of adder/subtractor 720. In particular,the value of x and a 23-bit constant of 0 are supplied as inputs to mux709, and mux 709 selects one of those values to supply as input toadder/subtractor 720. For example, if the corresponding equation fromTABLE 6 requires x as an operand rather than 2x, mux 709 selects theconstant of 0 as its output to adder/subtractor 720, since the value ofx has already been supplied directly through another input ofadder/subtractor 720. Alternatively, if the corresponding equation fromTABLE 6 requires 2x as an operand rather than x, mux 709 selects thevalue of x as its output to adder/subtractor 720, since that results inthe value of x being supplied through two inputs to adder/subtractor720.

Adder/subtractor 720 then performs the appropriate addition and/orsubtraction operations on these operands (e.g., based on the output ofrange selection logic 704), as required by the corresponding equationfrom TABLE 6. In this manner, the output of adder/subtractor 720corresponds to the final result for e^(x), which is equivalent to thenatural exponent constant e raised to the power of the mantissa of input701 (input[22:0]).

The output of mux 710 (e raised to the power of the unbiased exponent ofinput 701), and the output of adder/subtractor 720 (e raised to thepower of the mantissa of input 701), are then supplied as operands tomultiplier 712, which multiplies those values together in order togenerate the integer and fraction portions of the fixed-point output 703of exponent circuit 700.

FIG. 8 illustrates a flowchart 800 for an example processingarchitecture used to implement artificial neural networks (e.g., a deepneural network (DNN)). Flowchart 800 may be implemented, for example,using the embodiments and functionality described throughout thisdisclosure. For example, in some embodiments, flowchart 800 may beimplemented using the activation circuit of FIG. 2A-B or 4, the logcircuit of FIGS. 5A-C, the antilog circuit of FIGS. 6A-C, and/or theexponent circuit of FIG. 7 .

In the illustrated flowchart, a particular activation function isperformed by an activation function circuit that is designed toaccelerate performance of activation functions. In some embodiments, forexample, the activation function circuit may be designed to supportmultiple types of activation functions that are commonly used toimplement artificial or deep neural networks. Moreover, the activationfunction circuit may leverage log, antilog, and/or exponent circuitsimplemented using piecewise linear approximation in order to acceleratethe calculations associated with the supported activation functions.

In some embodiments, for example, the activation function circuit may beimplemented on and/or used in connection with processors, devices,and/or systems that execute applications with artificial neural networks(e.g., deep neural networks, convolutional neural networks, feedforwardneural networks, recurrent neural networks, and so forth). In thismanner, applications can leverage the activation function circuit inorder to accelerate the activation functions used to implementartificial neural networks. For example, an application with anartificial neural network may be stored in memory and executed by aprocessor on a particular device or system. When the application needsto perform an activation function in connection with an operation in theartificial neural network, the application may issue a correspondinginstruction or command to the processor and/or the activation functioncircuit, and the processor may then leverage the activation functioncircuit to perform the activation function. The result of the activationfunction may then be provided back to the processor and/or theapplication and subsequently used by the artificial neural network.

The flowchart begins at block 802, where an instruction or command toperform a particular activation function is received. The instruction orcommand, for example, may be issued by the application and received bythe processor and/or the activation function circuit. In someembodiments, the instruction or command may identify the desiredactivation function and any operands or other parameters associated withthe activation function.

Further, in some cases, the selected activation function may contain acombination of exponent, multiplication, and/or division operations.Accordingly, the flowchart first proceeds to block 804 to perform anyexponent operations associated with the activation function. In someembodiments, for example, the exponent operations may be performed usingpiecewise linear approximation in order to reduce the latency associatedwith those operations (e.g., using the exponent circuit of FIG. 7 ). Insome embodiments, however, if an exponent operation contains a base of2, it can be computed using an antilog circuit (using an antilog base 2operation) instead of the exponent circuit to reduce latency.

The flowchart then proceeds to block 806 to perform any multiplicationand/or division operations associated with the activation function. Insome embodiments, for example, multiplication and/or division operationsof the activation function may be performed using a combination of log,antilog, and addition/subtraction operations. For example, by leveragingthe properties of logarithmic functions, log and antilog operations canbe used to convert the expensive multiplication/division operations intoaddition and/or subtraction. Further, the log and antilog operations canbe performed using piecewise linear approximation in order to reduce thelatency associated with those operations.

In some embodiments, for example, a log circuit may be used to performlog operations using piecewise linear approximation (e.g., the logcircuit of FIGS. 5A-C). For example, the log circuit may be designed tocompute the logarithm of an input represented as a floating-point number(e.g., with an exponent and a mantissa), and the log circuit mayrepresent the resulting output as a fixed-point number (e.g., with aninteger and a fraction). The log circuit first identifies the input oroperand associated with the logarithm operation, and it then identifiesor determines a particular range that the input falls within forpurposes of piecewise linear approximation. For example, a plurality ofranges or segments, along with associated equations, are defined forperforming logarithm operations using piecewise linear approximation.Accordingly, the corresponding range that the input falls within isidentified, and the operands required by the equation for that range areobtained and/or generated. In some embodiments, for example, certainoperands may be extracted, obtained, and/or computed using the input,such as the mantissa of the input, as well as fraction operands withdenominators that are powers of 2, which may be generated using shiftcircuits (e.g., by shifting the bits in order to perform the division).The appropriate operands are then selected using one or moremultiplexers, and a result of the equation is computed using theselected operands. For example, the result may be computed by performingaddition and/or subtraction on the respective operands using anadder-subtractor circuit. Moreover, the exponent of the floating-pointinput may be converted into an unbiased exponent by subtracting a biasusing a subtractor circuit. The output of the logarithm operation isthen generated using the result from the corresponding equation and theunbiased exponent. For example, the unbiased exponent serves as theinteger of the resulting fixed-point output, and the result of theequation serves as the fraction of the fixed-point output.

Similarly, an antilog circuit may be used to perform the antilogoperations using piecewise linear approximation (e.g., the antilogcircuit of FIGS. 6A-C). The antilog operations may be implemented in asimilar manner, except using different computations for theinteger/exponent portion and different equations for piecewise linearapproximation.

The flowchart then proceeds to block 808 to output a result of theactivation function based on the results of the exponent,multiplication, and/or division operations.

At this point, the flowchart may be complete. In some embodiments,however, the flowchart may restart and/or certain blocks may berepeated. For example, in some embodiments, the flowchart may restart atblock 802 to continue performing activation functions.

DNN Performance

FIGS. 9A-B illustrate the scalability of the described embodiments withrespect to the supported number of parallel operations. In particular,the described embodiments are implemented using a flexible design thatenables the underlying hardware to be replicated in order to increasethe number of parallel operations that are supported. In this manner,the described embodiments can be scaled as necessary in order to supportthe number of parallel operations required by a particular applicationor use case. For example, as shown by FIGS. 9A-B, the proposed solutioncan simply be replicated in order to scale it from a single operand to noperands. In particular, FIG. 9A illustrates the proposed solution for asingle operand, whereas FIG. 9B illustrates the same for n operands.Further, the proposed solution can be pipelined to reduce latency andimprove throughput.

FIG. 10A illustrates the scalability of the described embodiments withrespect to precision. In particular, the described embodiments can bescaled to provide varying levels of precision by simply adjusting thenumber of segments in the piecewise linear approximation modelsimplemented by the log, antilog, and/or exponent circuits. In thismanner, the described embodiments can be scaled as necessary in order toprovide the level of precision required for different applications anduse cases. For example, if an application demands greater precision, thenumber of segments involved in the piecewise linear approximation modelscan be increased in order to accommodate the higher precisionrequirements.

The number of segments required in a piecewise linear approximationmodel for varying levels of precision is shown in FIG. 10A. As shown byFIG. 10A, for example, if an application demands 23-bit precision out ofa 23-bit mantissa, the piecewise linear approximation model should beimplemented using at least 1,556 segments. The number of segments usedfor piecewise linear approximation can be adjusted in a similar mannerin order to provide any requisite level of precision.

FIG. 10B compares the silicon area requirements for variousimplementations of log and antilog hardware. In particular, FIG. 10Billustrates the number of synthesis gates in a solution implementedusing the lookup table method (with 12-bit precision) versus log andantilog circuits implemented using piecewise linear approximation (PLA)(with either 10-bit or 12-bit precision). As shown in FIG. 10B, the logand antilog circuits implemented using piecewise linear approximationuse significantly fewer gates than the solution implemented using thelookup table method. For example, the lookup table solution uses 8,800gates for 12-bit precision, while the piecewise linear approximation(PLA) log and antilog circuits respectively use 350 and 450 gates for10-bit precision and 1,048 and 1,348 gates for 12-bit precision.

FIG. 10C compares the silicon area requirements for variousimplementations of activation function hardware (with 10-bit precision).In particular, FIG. 10C illustrates the number of synthesis gates forvarious individual activation functions implemented using lookup tables(LUTs) (e.g., Sigmoid, Hyperbolic Tangent (Tan h), and Swish), versusthe number of synthesis gates for a unified activation function circuitthat supports multiple activation functions and is implemented usingpiecewise linear approximation (PLA) (e.g., activation function circuit200 of FIGS. 2A-B). As shown in FIG. 10C, for example, the unifiedcircuit uses significantly fewer gates than any one of the LUT-basedcircuits, yet it supports multiple activation functions. For example,the unified circuit can be implemented using 8,321 total synthesisgates, as its simplified equations enable the exponent, logarithm, andantilogarithm blocks to be implemented using only 4,387, 1,048, and1,348 synthesis gates, respectively. By comparison, each LUT-basedcircuit requires approximately 17,000-18,000 synthesis gates for only asingle activation function.

FIG. 10D illustrates the approximation error for log and antilogcircuits implemented using piecewise linear approximation (e.g., FIGS.5A-C and 6A-C), while FIG. 10E illustrates the approximation error foran exponent circuit implemented using piecewise linear approximation(e.g., FIG. 7 ). In particular, these circuits can be implemented withan absolute error of 0.045% (ABS) for the respective log₂, and antilog₂,and exponent calculations, which translates into 12-bit precision inmantissa for an IEEE-754 single-precision floating-point number (e.g., 1sign bit+8 exponent bits+12-bit mantissa=21-bit precision).

The overall precision of a unified activation function circuitimplemented using the log, antilog, and exponent circuits (e.g., AFcircuit 200 of FIGS. 2A-B) is 10 mantissa bits for an IEEE-754single-precision floating-point number (e.g., 1 sign bit+8 exponentbits+10-bit mantissa=19-bit precision).

FIGS. 11A-C illustrate a performance comparison of deep neural networks(DNNs) implemented using traditional activation function equations (withpowers of the exponent constant e) versus modified activation functionequations (using powers of base 2). For example, as discussed above, AFcircuit 200 of FIGS. 2A-B and AF circuit 400 of FIG. 4 both leveragepiecewise linear approximation in order to implement activationfunctions. However, AF circuit 200 implements traditional activationfunctions, while AF circuit 400 implements modified activation functionsthat use powers of 2 instead of powers of the exponent constant e. Theperformance of these respective approaches is compared in the exampleillustrated by FIGS. 11A-C.

FIG. 11A illustrates an example DNN 1100 that includes an input layerwith two input neurons, a single hidden layer with three neurons, and afully connected layer with one output neuron. For simplicity, DNN 1100implements the feature mapping shown in TABLE 7, which has the samebehavior of an XOR gate.

TABLE 7 Mapping of DNN feature sets FEATURE A FEATURE B OUTPUT 0 0 0 0 11 1 0 1 1 1 0

The illustrated example focuses on one of these feature sets, namely A=1and B=1, which is expected to have an output of 0. In the illustratedexample, input neuron X1 corresponds to feature A and input neuron X2corresponds to feature B.

FIG. 11B illustrates the processing that is performed when DNN 1100 isimplemented using the traditional Sigmoid activation function:

${f(x)} = {\frac{1}{1 + e^{- x}}.}$During the forward propagation stage, the weights are selected randomlyas follows: W11=0.8, W12=0.4, W13=0.3, W21=0.2, W22=0.9, WW23=0.5,Wh1=0.3, Wh2=0.5, and Wh3=0.9. The output of the hidden layer nodes (H)is then computed as follows:H1=X1*W11+X2*W21=0.8+0.2=1;H2=X1*W12+X2*W22=0.4+0.9=1.3;H3=X1*W13+X2*W23=0.3+0.5=0.8.

A bias of 0 is taken in the illustrated example for simplicity. Afterapplying the Sigmoid activation function, the updated hidden layerneurons have the following values:H1=0.7310;H2=0.7858;H3=0.6899.

The fully connected (FC) layer can then be computed as:FC=H1*Wh1+H2*Wh2+H3*Wh3=0.7310*0.3+0.7858*0.5+0.6899*0.9=1.235. Afterapplying the Sigmoid activation function to the fully connected layer,FC=0.7746. The error is then computed as follows:error=expected−calculated=0-0.7746=−0.7746.

During the backwards propagation and weight update stage, the derivativeof the Sigmoid activation function

${f^{\prime}(x)} = \frac{e^{- x}}{\left( {1 + e^{- x}} \right)^{2}}$is used, and the following calculations are performed:ΔFC=f′(FC value without activationfunction)*error=f′(1.235)*(−0.7746)=−0.13439;ΔFC=hidden layer neurons*hidden layer weights=H1*Wh1+H2*Wh2+H3*Wh3;ΔWh1=ΔFC/H1=−0.13439/0.7310=−0.1838;ΔWh2=ΔFC/H2=−0.13439/0.7858=−0.1710;ΔWh3=ΔFC/H3=−0.13439/0.6899=−0.1920.

The following calculations are then performed with respect to ΔH1, ΔH2and ΔH3:New hidden layer values=ΔFC*f′(hidden layer neuron values withoutactivation function)/hidden layer weights:ΔH1=ΔFC*f′(1)/Wh1=−0.13439*0.1966/0.3=−0.088;ΔH2=ΔFC*f′(1.3)/Wh2=−0.13439*0.1683=−0.0452;ΔH1=ΔFC*f′(0.8)/Wh3=−0.13439*0.2139=−0.0319.

After back propagation, the new hidden layer weights have the followingvalues:Wh1=Wh1+ΔWh1=0.3−0.1838=0.1162;Wh2=Wh2+ΔWh2=0.5−0.1710=0.392;Wh3=Wh3+ΔWh3=0.9−0.1920=0.708.

The weight update between the input and hidden layers is then computedas follows:Delta of weights=delta of hidden layer/inputs:ΔW11=ΔH1/X1=−0.088/1=−0.088;ΔW12=ΔH2/X1=−0.0452/1=−0.0452;ΔW13=ΔH3/X1=−0.0319/1=−0.0319;ΔW21=ΔH1/X2=−0.088/1=−0.088;ΔW22=ΔH2/X2=−0.0452/1=−0.0452;ΔW23=ΔH3/X2=−0.0319/1=−0.0319;New weights:W11=W11+ΔW11=0.8−0.088=0.712;W12=W12+ΔW12=0.4−0.0452=0.3548;W13=W13+ΔW13=0.3−0.0319=0.2681;W21=W21+ΔW21=0.2−0.088=0.112;W22=W22+ΔW22=0.9−0.0452=0.8548;W23=W23+ΔW23=0.5−0.0319=0.4681.

FIG. 11B illustrates the state of DNN 1100 after the weights have beenupdated based on the calculations above. The output of the DNN is 0.69after this iteration, which is an improvement over the output of 0.77after the first iteration. The iterations continue in this manner untilthe loss function gradient reaches an acceptable level.

FIG. 11C illustrates the processing that is performed when DNN 1100 isimplemented using the modified Sigmoid activation function, which has anexponent term with a base of 2 instead of a base of e:

${f(x)} = {\frac{1}{1 + 2^{- x}}.}$

During the forward propagation stage, the weights are selected randomlyas follows: W1=0.8, W12=0.4, W13=0.3, W21=0.2, W22=0.9, WW23=0.5,Wh1=0.3, Wh2=0.5, and Wh3=0.9. The output of the hidden layer nodes (H)is then computed as follows:H1=X1*W11+X2*W21=0.8+0.2=1;H2=X1*W12+X2*W22=0.4+0.9=1.3;H3=X1*W13+X2*W23=0.3+0.5=0.8.

A bias of 0 is taken in the illustrated example for simplicity. Afterapplying the modified Sigmoid activation function, the updated hiddenlayer neurons have the following values:H1=0.6667;H2=0.7117;H3=0.6351.

The fully connected (FC) layer can then be computed as:FC=H1*Wh1+H2*Wh2+H3*Wh3=0.6667*0.3+0.7117*0.5+0.6351*0.9=1.1272. Afterapplying the modified Sigmoid activation function to the fully connectedlayer, FC=0.6859. The error is then computed as follows:error=expected−calculated=0−0.6859=−0.6859.

During the backwards propagation and weight update stage, the derivativeof the modified Sigmoid activation function

${f^{\prime}(x)} = \frac{{\ln(2)} \cdot 2^{x}}{\left( {1 + 2^{- x}} \right)^{2}}$is used, and the following calculations are performed:ΔFC=f′(FC value without activationfunction)*error=f′(1.1272)*(−0.6859)=−0.1024;ΔFC=hidden layer neurons*hidden layer weights=H1*Wh1+H2*Wh2+H3*Wh3;ΔWh1=ΔFC/H1=−0.1024/0.6667=−0.15364;ΔWh2=ΔFC/H2=−0.1024/0.7117=−0.14402;ΔWh3=ΔFC/H3=−0.1024/0.6351=−0.16125.

The following calculations are then performed with respect to ΔH1, ΔH2and ΔH3:New hidden layer values=ΔFC*f′(hidden layer neuron values withoutactivation function)/hidden layer weights:ΔH1=ΔFC*f′(1)/Wh1=−0.13439*0.1966/0.3=−0.05259;ΔH2=ΔFC*f′(1.3)/Wh2=−0.13439*0.1683=−0.02917;ΔH1=ΔFC*f′(0.8)/Wh3=−0.13439*0.2139=−0.01828.

After back propagation, the new hidden layer weights have the followingvalues:Wh1=Wh1+ΔWh1=0.3−0.15364=0.1463;Wh2=Wh2+ΔWh2=0.5−0.14402=0.3559;Wh3=Wh3+ΔWh3=0.9−0.16125=0.7387.

The weight update between the input and hidden layers is then computedas follows:Delta of weights=delta of hidden layer/inputs:ΔW11=ΔH1/X1=−0.05259/1=−0.05259;ΔW12=ΔH2/X1=−0.02917/1=−0.02917;ΔW13=ΔH3/X1=−0.01828/1=−0.01828;ΔW21=ΔH1/X2=−0.02917/1=−0.05259;ΔW22=ΔH2/X2=−0.0452/1=−0.02917;ΔW23=ΔH3/X2=−0.01828/1=−0.01828;New weights:W11=W11+ΔW11=0.8−0.05259=0.7474;W12=W12+ΔW12=0.4−0.02917=0.3708;W13=W13+ΔW13=0.3−0.01828=0.2817;W21=W21+ΔW21=0.2−0.05259=0.1474;W22=W22+ΔW22=0.9−0.02917=0.8708;W23=W23+ΔW23=0.5−0.01828=0.4817.

FIG. 11C illustrates the state of DNN 1100 after the weights have beenupdated based on the calculations above (e.g., using the modifiedSigmoid activation function). The output of the DNN of FIG. 11C is 0.70after this iteration, which is comparable to the output of 0.69 for theDNN of FIG. 11B. The iterations continue in this manner until the lossfunction gradient reaches an acceptable level.

FIGS. 12A-B illustrate a comparison of the training convergence for therespective DNNs of FIGS. 11B and 11C. In particular, FIG. 12Aillustrates the rate of convergence for the original Sigmoid activationfunction used by the DNN of FIG. 11B, while FIG. 12B illustrates therate of convergence for the modified Sigmoid activation function (e.g.,using a power of base 2 instead of e) used by the DNN of FIG. 11C. FIG.13 illustrates the error percentage or accuracy of these approaches.

Example Computing Architectures

FIGS. 14-18 illustrate example implementations of computing environmentsand architectures that can be used in accordance with embodimentsdisclosed herein. In various embodiments, for example, these examplecomputer architectures may be used in conjunction with and/or used toimplement the Deep Neural Network (DNN) processing functionalitydescribed throughout this disclosure.

Other system designs and configurations known in the arts for laptops,desktops, handheld PCs, personal digital assistants, engineeringworkstations, servers, network devices, network hubs, switches, embeddedprocessors, digital signal processors (DSPs), graphics devices, videogame devices, set-top boxes, micro controllers, cell phones, portablemedia players, hand held devices, and various other electronic devices,are also suitable. In general, a huge variety of systems or electronicdevices capable of incorporating a processor and/or other executionlogic as disclosed herein are generally suitable.

FIG. 14A is a block diagram illustrating both an exemplary in-orderpipeline and an exemplary register renaming, out-of-orderissue/execution pipeline according to embodiments of the invention. FIG.14B is a block diagram illustrating both an exemplary embodiment of anin-order architecture core and an exemplary register renaming,out-of-order issue/execution architecture core to be included in aprocessor according to embodiments of the invention. The solid linedboxes in FIGS. 14A-B illustrate the in-order pipeline and in-order core,while the optional addition of the dashed lined boxes illustrates theregister renaming, out-of-order issue/execution pipeline and core. Giventhat the in-order aspect is a subset of the out-of-order aspect, theout-of-order aspect will be described.

In FIG. 14A, a processor pipeline 1400 includes a fetch stage 1402, alength decode stage 1404, a decode stage 1406, an allocation stage 1408,a renaming stage 1410, a scheduling (also known as a dispatch or issue)stage 1412, a register read/memory read stage 1414, an execute stage1416, a write back/memory write stage 1418, an exception handling stage1422, and a commit stage 1424.

FIG. 14B shows processor core 1490 including a front end unit 1430coupled to an execution engine unit 1450, and both are coupled to amemory unit 1470. The core 1490 may be a reduced instruction setcomputing (RISC) core, a complex instruction set computing (CISC) core,a very long instruction word (VLIW) core, or a hybrid or alternativecore type. As yet another option, the core 1490 may be a special-purposecore, such as, for example, a network or communication core, compressionengine, coprocessor core, general purpose computing graphics processingunit (GPGPU) core, graphics core, or the like.

The front end unit 1430 includes a branch prediction unit 1432 coupledto an instruction cache unit 1434, which is coupled to an instructiontranslation lookaside buffer (TLB) 1436, which is coupled to aninstruction fetch unit 1438, which is coupled to a decode unit 1440. Thedecode unit 1440 (or decoder) may decode instructions, and generate asan output one or more micro-operations, micro-code entry points,microinstructions, other instructions, or other control signals, whichare decoded from, or which otherwise reflect, or are derived from, theoriginal instructions. The decode unit 1440 may be implemented usingvarious different mechanisms. Examples of suitable mechanisms include,but are not limited to, look-up tables, hardware implementations,programmable logic arrays (PLAs), microcode read only memories (ROMs),etc. In one embodiment, the core 1490 includes a microcode ROM or othermedium that stores microcode for certain macroinstructions (e.g., indecode unit 1440 or otherwise within the front end unit 1430). Thedecode unit 1440 is coupled to a rename/allocator unit 1452 in theexecution engine unit 1450.

The execution engine unit 1450 includes the rename/allocator unit 1452coupled to a retirement unit 1454 and a set of one or more schedulerunit(s) 1456. The scheduler unit(s) 1456 represents any number ofdifferent schedulers, including reservations stations, centralinstruction window, etc. The scheduler unit(s) 1456 is coupled to thephysical register file(s) unit(s) 1458. Each of the physical registerfile(s) units 1458 represents one or more physical register files,different ones of which store one or more different data types, such asscalar integer, scalar floating point, packed integer, packed floatingpoint, vector integer, vector floating point, status (e.g., aninstruction pointer that is the address of the next instruction to beexecuted), etc. In one embodiment, the physical register file(s) unit1458 comprises a vector registers unit, a write mask registers unit, anda scalar registers unit. These register units may provide architecturalvector registers, vector mask registers, and general purpose registers.The physical register file(s) unit(s) 1458 is overlapped by theretirement unit 1454 to illustrate various ways in which registerrenaming and out-of-order execution may be implemented (e.g., using areorder buffer(s) and a retirement register file(s); using a futurefile(s), a history buffer(s), and a retirement register file(s); using aregister maps and a pool of registers; etc.). The retirement unit 1454and the physical register file(s) unit(s) 1458 are coupled to theexecution cluster(s) 1460. The execution cluster(s) 1460 includes a setof one or more execution units 1462 and a set of one or more memoryaccess units 1464. The execution units 1462 may perform variousoperations (e.g., shifts, addition, subtraction, multiplication) and onvarious types of data (e.g., scalar floating point, packed integer,packed floating point, vector integer, vector floating point). Whilesome embodiments may include a number of execution units dedicated tospecific functions or sets of functions, other embodiments may includeonly one execution unit or multiple execution units that all perform allfunctions. The scheduler unit(s) 1456, physical register file(s) unit(s)1458, and execution cluster(s) 1460 are shown as being possibly pluralbecause certain embodiments create separate pipelines for certain typesof data/operations (e.g., a scalar integer pipeline, a scalar floatingpoint/packed integer/packed floating point/vector integer/vectorfloating point pipeline, and/or a memory access pipeline that each havetheir own scheduler unit, physical register file(s) unit, and/orexecution cluster—and in the case of a separate memory access pipeline,certain embodiments are implemented in which only the execution clusterof this pipeline has the memory access unit(s) 1464). It should also beunderstood that where separate pipelines are used, one or more of thesepipelines may be out-of-order issue/execution and the rest in-order.

The set of memory access units 1464 is coupled to the memory unit 1470,which includes a data TLB unit 1472 coupled to a data cache unit 1474coupled to a level 2 (L2) cache unit 1476. In one exemplary embodiment,the memory access units 1464 may include a load unit, a store addressunit, and a store data unit, each of which is coupled to the data TLBunit 1472 in the memory unit 1470. The instruction cache unit 1434 isfurther coupled to a level 2 (L2) cache unit 1476 in the memory unit1470. The L2 cache unit 1476 is coupled to one or more other levels ofcache and eventually to a main memory.

By way of example, the exemplary register renaming, out-of-orderissue/execution core architecture may implement the pipeline 1400 asfollows: 1) the instruction fetch 1438 performs the fetch and lengthdecoding stages 1402 and 1404; 2) the decode unit 1440 performs thedecode stage 1406; 3) the rename/allocator unit 1452 performs theallocation stage 1408 and renaming stage 1410; 4) the scheduler unit(s)1456 performs the schedule stage 1412; 5) the physical register file(s)unit(s) 1458 and the memory unit 1470 perform the register read/memoryread stage 1414; the execution cluster 1460 perform the execute stage1416; 6) the memory unit 1470 and the physical register file(s) unit(s)1458 perform the write back/memory write stage 1418; 7) various unitsmay be involved in the exception handling stage 1422; and 8) theretirement unit 1454 and the physical register file(s) unit(s) 1458perform the commit stage 1424.

The core 1490 may support one or more instructions sets (e.g., the x86instruction set (with some extensions that have been added with newerversions); the MIPS instruction set of MIPS Technologies of Sunnyvale,Calif.; the ARM instruction set (with optional additional extensionssuch as NEON) of ARM Holdings of Sunnyvale, Calif.), including theinstruction(s) described herein. In one embodiment, the core 1490includes logic to support a packed data instruction set extension (e.g.,AVX1, AVX2), thereby allowing the operations used by many multimediaapplications to be performed using packed data.

It should be understood that the core may support multithreading(executing two or more parallel sets of operations or threads), and maydo so in a variety of ways including time sliced multithreading,simultaneous multithreading (where a single physical core provides alogical core for each of the threads that physical core issimultaneously multithreading), or a combination thereof (e.g., timesliced fetching and decoding and simultaneous multithreading thereaftersuch as in the Intel® Hyperthreading technology).

While register renaming is described in the context of out-of-orderexecution, it should be understood that register renaming may be used inan in-order architecture. While the illustrated embodiment of theprocessor also includes separate instruction and data cache units1434/1474 and a shared L2 cache unit 1476, alternative embodiments mayhave a single internal cache for both instructions and data, such as,for example, a Level 1 (L1) internal cache, or multiple levels ofinternal cache. In some embodiments, the system may include acombination of an internal cache and an external cache that is externalto the core and/or the processor. Alternatively, all of the cache may beexternal to the core and/or the processor.

FIG. 15 is a block diagram of a processor 1500 that may have more thanone core, may have an integrated memory controller, and may haveintegrated graphics according to embodiments of the invention. The solidlined boxes in FIG. 15 illustrate a processor 1500 with a single core1502A, a system agent 1510, a set of one or more bus controller units1516, while the optional addition of the dashed lined boxes illustratesan alternative processor 1500 with multiple cores 1502A-N, a set of oneor more integrated memory controller unit(s) 1514 in the system agentunit 1510, and special purpose logic 1508.

Thus, different implementations of the processor 1500 may include: 1) aCPU with the special purpose logic 1508 being integrated graphics and/orscientific (throughput) logic (which may include one or more cores), andthe cores 1502A-N being one or more general purpose cores (e.g., generalpurpose in-order cores, general purpose out-of-order cores, acombination of the two); 2) a coprocessor with the cores 1502A-N being alarge number of special purpose cores intended primarily for graphicsand/or scientific (throughput); and 3) a coprocessor with the cores1502A-N being a large number of general purpose in-order cores. Thus,the processor 1500 may be a general-purpose processor, coprocessor orspecial-purpose processor, such as, for example, a network orcommunication processor, compression engine, graphics processor, GPGPU(general purpose graphics processing unit), a high-throughput manyintegrated core (MIC) coprocessor (including 30 or more cores), embeddedprocessor, or the like. The processor may be implemented on one or morechips. The processor 1500 may be a part of and/or may be implemented onone or more substrates using any of a number of process technologies,such as, for example, BiCMOS, CMOS, or NMOS.

The memory hierarchy includes one or more levels of cache 1504A-N withinthe cores, a set or one or more shared cache units 1506, and externalmemory (not shown) coupled to the set of integrated memory controllerunits 1514. The set of shared cache units 1506 may include one or moremid-level caches, such as level 2 (L2), level 3 (L3), level 4 (L4), orother levels of cache, a last level cache (LLC), and/or combinationsthereof. While in one embodiment a ring based interconnect unit 1512interconnects the integrated graphics logic 1508, the set of sharedcache units 1506, and the system agent unit 1510/integrated memorycontroller unit(s) 1514, alternative embodiments may use any number ofwell-known techniques for interconnecting such units. In one embodiment,coherency is maintained between one or more cache units 1506 and cores1502-A-N.

In some embodiments, one or more of the cores 1502A-N are capable ofmulti-threading. The system agent 1510 includes those componentscoordinating and operating cores 1502A-N. The system agent unit 1510 mayinclude for example a power control unit (PCU) and a display unit. ThePCU may be or include logic and components needed for regulating thepower state of the cores 1502A-N and the integrated graphics logic 1508.The display unit is for driving one or more externally connecteddisplays.

The cores 1502A-N may be homogenous or heterogeneous in terms ofarchitecture instruction set; that is, two or more of the cores 1502A-Nmay be capable of execution the same instruction set, while others maybe capable of executing only a subset of that instruction set or adifferent instruction set.

Referring now to FIG. 16 , shown is a block diagram of a system 1600 inaccordance with one embodiment of the present invention. The system 1600may include one or more processors 1610, 1615, which are coupled to acontroller hub 1620. In one embodiment the controller hub 1620 includesa graphics memory controller hub (GMCH) 1690 and an Input/Output Hub(IOH) 1650 (which may be on separate chips); the GMCH 1690 includesmemory and graphics controllers to which are coupled memory 1640 and acoprocessor 1645; the IOH 1650 is couples input/output (I/O) devices1660 to the GMCH 1690. Alternatively, one or both of the memory andgraphics controllers are integrated within the processor (as describedherein), the memory 1640 and the coprocessor 1645 are coupled directlyto the processor 1610, and the controller hub 1620 in a single chip withthe IOH 1650.

The optional nature of additional processors 1615 is denoted in FIG. 16with broken lines. Each processor 1610, 1615 may include one or more ofthe processing cores described herein and may be some version of theprocessor 1500.

The memory 1640 may be, for example, dynamic random access memory(DRAM), phase change memory (PCM), or a combination of the two. For atleast one embodiment, the controller hub 1620 communicates with theprocessor(s) 1610, 1615 via a multi-drop bus, such as a frontside bus(FSB), point-to-point interface such as QuickPath Interconnect (QPI), orsimilar connection 1695.

In one embodiment, the coprocessor 1645 is a special-purpose processor,such as, for example, a high-throughput MIC processor, a network orcommunication processor, compression engine, graphics processor, GPGPU,embedded processor, or the like. In one embodiment, controller hub 1620may include an integrated graphics accelerator.

There can be a variety of differences between the physical resources1610, 1615 in terms of a spectrum of metrics of merit includingarchitectural, microarchitectural, thermal, power consumptioncharacteristics, and the like.

In one embodiment, the processor 1610 executes instructions that controldata processing operations of a general type. Embedded within theinstructions may be coprocessor instructions. The processor 1610recognizes these coprocessor instructions as being of a type that shouldbe executed by the attached coprocessor 1645. Accordingly, the processor1610 issues these coprocessor instructions (or control signalsrepresenting coprocessor instructions) on a coprocessor bus or otherinterconnect, to coprocessor 1645. Coprocessor(s) 1645 accept andexecute the received coprocessor instructions.

Referring now to FIG. 17 , shown is a block diagram of a first morespecific exemplary system 1700 in accordance with an embodiment of thepresent invention. As shown in FIG. 17 , multiprocessor system 1700 is apoint-to-point interconnect system, and includes a first processor 1770and a second processor 1780 coupled via a point-to-point interconnect1750. Each of processors 1770 and 1780 may be some version of theprocessor 1500. In one embodiment of the invention, processors 1770 and1780 are respectively processors 1610 and 1615, while coprocessor 1738is coprocessor 1645. In another embodiment, processors 1770 and 1780 arerespectively processor 1610 coprocessor 1645.

Processors 1770 and 1780 are shown including integrated memorycontroller (IMC) units 1772 and 1782, respectively. Processor 1770 alsoincludes as part of its bus controller units point-to-point (P-P)interfaces 1776 and 1778; similarly, second processor 1780 includes P-Pinterfaces 1786 and 1788. Processors 1770, 1780 may exchange informationvia a point-to-point (P-P) interface 1750 using P-P interface circuits1778, 1788. As shown in FIG. 17 , IMCs 1772 and 1782 couple theprocessors to respective memories, namely a memory 1732 and a memory1734, which may be portions of main memory locally attached to therespective processors.

Processors 1770, 1780 may each exchange information with a chipset 1790via individual P-P interfaces 1752, 1754 using point to point interfacecircuits 1776, 1794, 1786, 1798. Chipset 1790 may optionally exchangeinformation with the coprocessor 1738 via a high-performance interface1739. In one embodiment, the coprocessor 1738 is a special-purposeprocessor, such as, for example, a high-throughput MIC processor, anetwork or communication processor, compression engine, graphicsprocessor, GPGPU, embedded processor, or the like.

A shared cache (not shown) may be included in either processor oroutside of both processors, yet connected with the processors via P-Pinterconnect, such that either or both processors' local cacheinformation may be stored in the shared cache if a processor is placedinto a low power mode.

Chipset 1790 may be coupled to a first bus 1716 via an interface 1796.In one embodiment, first bus 1716 may be a Peripheral ComponentInterconnect (PCI) bus, or a bus such as a PCI Express bus or anotherthird generation I/O interconnect bus, although the scope of the presentinvention is not so limited.

As shown in FIG. 17 , various I/O devices 1714 may be coupled to firstbus 1716, along with a bus bridge 1718 which couples first bus 1716 to asecond bus 1720. In one embodiment, one or more additional processor(s)1715, such as coprocessors, high-throughput MIC processors, GPGPU's,accelerators (such as, e.g., graphics accelerators or digital signalprocessing (DSP) units), field programmable gate arrays, or any otherprocessor, are coupled to first bus 1716. In one embodiment, second bus1720 may be a low pin count (LPC) bus. Various devices may be coupled toa second bus 1720 including, for example, a keyboard and/or mouse 1722,communication devices 1727 and a storage unit 1728 such as a disk driveor other mass storage device which may include instructions/code anddata 1730, in one embodiment. Further, an audio I/O 1724 may be coupledto the second bus 1720. Note that other architectures are possible. Forexample, instead of the point-to-point architecture of FIG. 17 , asystem may implement a multi-drop bus or other such architecture.

Referring now to FIG. 18 , shown is a block diagram of a SoC 1800 inaccordance with an embodiment of the present invention. Similar elementsin FIG. 15 bear like reference numerals. Also, dashed lined boxes areoptional features on more advanced SoCs. In FIG. 18 , an interconnectunit(s) 1812 is coupled to: an application processor 1810 which includesa set of one or more cores 1802A-N, cache unit(s) 1804A-N, and sharedcache unit(s) 1806; a system agent unit 1810; a bus controller unit(s)1816; an integrated memory controller unit(s) 1814; a set or one or morecoprocessors 1820 which may include integrated graphics logic, an imageprocessor, an audio processor, and a video processor; an static randomaccess memory (SRAM) unit 1830; a direct memory access (DMA) unit 1832;and a display unit 1840 for coupling to one or more external displays.In one embodiment, the coprocessor(s) 1820 include a special-purposeprocessor, such as, for example, a network or communication processor,compression engine, GPGPU, a high-throughput MIC processor, embeddedprocessor, or the like.

Embodiments of the mechanisms disclosed herein may be implemented inhardware, software, firmware, or a combination of such implementationapproaches. Embodiments of the invention may be implemented as computerprograms or program code executing on programmable systems comprising atleast one processor, a storage system (including volatile andnon-volatile memory and/or storage elements), at least one input device,and at least one output device.

Program code, such as code 1730 illustrated in FIG. 17 , may be appliedto input instructions to perform the functions described herein andgenerate output information. The output information may be applied toone or more output devices, in known fashion. For purposes of thisapplication, a processing system includes any system that has aprocessor, such as, for example; a digital signal processor (DSP), amicrocontroller, an application specific integrated circuit (ASIC), or amicroprocessor.

The program code may be implemented in a high level procedural or objectoriented programming language to communicate with a processing system.The program code may also be implemented in assembly or machinelanguage, if desired. In fact, the mechanisms described herein are notlimited in scope to any particular programming language. In any case,the language may be a compiled or interpreted language.

One or more aspects of at least one embodiment may be implemented byrepresentative instructions stored on a machine-readable medium whichrepresents various logic within the processor, which when read by amachine causes the machine to fabricate logic to perform the techniquesdescribed herein. Such representations, known as “IP cores” may bestored on a tangible, machine readable medium and supplied to variouscustomers or manufacturing facilities to load into the fabricationmachines that actually make the logic or processor.

Such machine-readable storage media may include, without limitation,non-transitory, tangible arrangements of articles manufactured or formedby a machine or device, including storage media such as hard disks, anyother type of disk including floppy disks, optical disks, compact diskread-only memories (CD-ROMs), compact disk rewritable's (CD-RWs), andmagneto-optical disks, semiconductor devices such as read-only memories(ROMs), random access memories (RAMs) such as dynamic random accessmemories (DRAMs), static random access memories (SRAMs), erasableprogrammable read-only memories (EPROMs), flash memories, electricallyerasable programmable read-only memories (EEPROMs), phase change memory(PCM), magnetic or optical cards, or any other type of media suitablefor storing electronic instructions.

Accordingly, embodiments of the invention also include non-transitory,tangible machine-readable media containing instructions or containingdesign data, such as Hardware Description Language (HDL), which definesstructures, circuits, apparatuses, processors and/or system featuresdescribed herein. Such embodiments may also be referred to as programproducts.

The flowcharts and block diagrams in the FIGURES illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods and computer program products according to variousaspects of the present disclosure. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof code, which comprises one or more executable instructions forimplementing the specified logical function(s). It should also be notedthat, in some alternative implementations, the functions noted in theblock may occur out of the order noted in the figures. For example, twoblocks shown in succession may, in fact, be executed substantiallyconcurrently, or the blocks may sometimes be executed in the reverseorder or alternative orders, depending upon the functionality involved.It will also be noted that each block of the block diagrams and/orflowchart illustration, and combinations of blocks in the block diagramsand/or flowchart illustration, can be implemented by special purposehardware-based systems that perform the specified functions or acts, orcombinations of special purpose hardware and computer instructions.

The foregoing disclosure outlines features of several embodiments sothat those skilled in the art may better understand various aspects ofthe present disclosure. Those skilled in the art should appreciate thatthey may readily use the present disclosure as a basis for designing ormodifying other processes and structures for carrying out the samepurposes and/or achieving the same advantages of the embodimentsintroduced herein. Those skilled in the art should also realize thatsuch equivalent constructions do not depart from the spirit and scope ofthe present disclosure, and that they may make various changes,substitutions, and alterations herein without departing from the spiritand scope of the present disclosure.

All or part of any hardware element disclosed herein may readily beprovided in a system-on-a-chip (SoC), including a central processingunit (CPU) package. An SoC represents an integrated circuit (IC) thatintegrates components of a computer or other electronic system into asingle chip. The SoC may contain digital, analog, mixed-signal, andradio frequency functions, all of which may be provided on a single chipsubstrate. Other embodiments may include a multi-chip-module (MCM), witha plurality of chips located within a single electronic package andconfigured to interact closely with each other through the electronicpackage. In various other embodiments, the computing functionalitiesdisclosed herein may be implemented in one or more silicon cores inApplication Specific Integrated Circuits (ASICs), Field ProgrammableGate Arrays (FPGAs), and other semiconductor chips.

As used throughout this specification, the term “processor” or“microprocessor” should be understood to include not only a traditionalmicroprocessor (such as Intel's® industry-leading x86 and x64architectures), but also graphics processors, matrix processors, and anyASIC, FPGA, microcontroller, digital signal processor (DSP),programmable logic device, programmable logic array (PLA), microcode,instruction set, emulated or virtual machine processor, or any similar“Turing-complete” device, combination of devices, or logic elements(hardware or software) that permit the execution of instructions.

Note also that in certain embodiments, some of the components may beomitted or consolidated. In a general sense, the arrangements depictedin the figures should be understood as logical divisions, whereas aphysical architecture may include various permutations, combinations,and/or hybrids of these elements. It is imperative to note thatcountless possible design configurations can be used to achieve theoperational objectives outlined herein. Accordingly, the associatedinfrastructure has a myriad of substitute arrangements, design choices,device possibilities, hardware configurations, software implementations,and equipment options.

In a general sense, any suitably-configured processor can executeinstructions associated with data or microcode to achieve the operationsdetailed herein. Any processor disclosed herein could transform anelement or an article (for example, data) from one state or thing toanother state or thing. In another example, some activities outlinedherein may be implemented with fixed logic or programmable logic (forexample, software and/or computer instructions executed by a processor)and the elements identified herein could be some type of a programmableprocessor, programmable digital logic (for example, a field programmablegate array (FPGA), an erasable programmable read only memory (EPROM), anelectrically erasable programmable read only memory (EEPROM)), an ASICthat includes digital logic, software, code, electronic instructions,flash memory, optical disks, CD-ROMs, DVD ROMs, magnetic or opticalcards, other types of machine-readable mediums suitable for storingelectronic instructions, or any suitable combination thereof.

In operation, a storage may store information in any suitable type oftangible, non-transitory storage medium (for example, random accessmemory (RAM), read only memory (ROM), field programmable gate array(FPGA), erasable programmable read only memory (EPROM), electricallyerasable programmable ROM (EEPROM), or microcode), software, hardware(for example, processor instructions or microcode), or in any othersuitable component, device, element, or object where appropriate andbased on particular needs. Furthermore, the information being tracked,sent, received, or stored in a processor could be provided in anydatabase, register, table, cache, queue, control list, or storagestructure, based on particular needs and implementations, all of whichcould be referenced in any suitable timeframe. Any of the memory orstorage elements disclosed herein should be construed as beingencompassed within the broad terms ‘memory’ and ‘storage,’ asappropriate. A non-transitory storage medium herein is expresslyintended to include any non-transitory special-purpose or programmablehardware configured to provide the disclosed operations, or to cause aprocessor to perform the disclosed operations. A non-transitory storagemedium also expressly includes a processor having stored thereonhardware-coded instructions, and optionally microcode instructions orsequences encoded in hardware, firmware, or software.

Computer program logic implementing all or part of the functionalitydescribed herein is embodied in various forms, including, but in no waylimited to, hardware description language, a source code form, acomputer executable form, machine instructions or microcode,programmable hardware, and various intermediate forms (for example,forms generated by an HDL processor, assembler, compiler, linker, orlocator). In an example, source code includes a series of computerprogram instructions implemented in various programming languages, suchas an object code, an assembly language, or a high-level language suchas OpenCL, FORTRAN, C, C++, JAVA, or HTML for use with various operatingsystems or operating environments, or in hardware description languagessuch as Spice, Verilog, and VHDL. The source code may define and usevarious data structures and communication messages. The source code maybe in a computer executable form (e.g., via an interpreter), or thesource code may be converted (e.g., via a translator, assembler, orcompiler) into a computer executable form, or converted to anintermediate form such as byte code. Where appropriate, any of theforegoing may be used to build or describe appropriate discrete orintegrated circuits, whether sequential, combinatorial, state machines,or otherwise.

In one example, any number of electrical circuits of the FIGURES may beimplemented on a board of an associated electronic device. The board canbe a general circuit board that can hold various components of theinternal electronic system of the electronic device and, further,provide connectors for other peripherals. More specifically, the boardcan provide the electrical connections by which the other components ofthe system can communicate electrically. Any suitable processor andmemory can be suitably coupled to the board based on particularconfiguration needs, processing demands, and computing designs. Othercomponents such as external storage, additional sensors, controllers foraudio/video display, and peripheral devices may be attached to the boardas plug-in cards, via cables, or integrated into the board itself. Inanother example, the electrical circuits of the FIGURES may beimplemented as stand-alone modules (e.g., a device with associatedcomponents and circuitry configured to perform a specific application orfunction) or implemented as plug-in modules into application specifichardware of electronic devices.

Note that with the numerous examples provided herein, interaction may bedescribed in terms of two, three, four, or more electrical components.However, this has been done for purposes of clarity and example only. Itshould be appreciated that the system can be consolidated orreconfigured in any suitable manner. Along similar design alternatives,any of the illustrated components, modules, and elements of the FIGURESmay be combined in various possible configurations, all of which arewithin the broad scope of this specification. In certain cases, it maybe easier to describe one or more of the functionalities of a given setof flows by only referencing a limited number of electrical elements. Itshould be appreciated that the electrical circuits of the FIGURES andits teachings are readily scalable and can accommodate a large number ofcomponents, as well as more complicated/sophisticated arrangements andconfigurations. Accordingly, the examples provided should not limit thescope or inhibit the broad teachings of the electrical circuits aspotentially applied to a myriad of other architectures.

Numerous other changes, substitutions, variations, alterations, andmodifications may be ascertained to one skilled in the art and it isintended that the present disclosure encompass all such changes,substitutions, variations, alterations, and modifications as fallingwithin the scope of the appended claims.

Example Implementations

The following examples pertain to embodiments described throughout thisdisclosure.

One or more embodiments may include an apparatus, comprising: a logcircuit, wherein the log circuit comprises circuitry to: identify, viaan input register, an input associated with a logarithm operation,wherein the logarithm operation is to be performed by the log circuitusing piecewise linear approximation; identify, using range selectioncircuitry, a first range that the input falls within, wherein the firstrange is identified from a plurality of ranges associated with aplurality of piecewise linear approximation (PLA) equations for thelogarithm operation, and wherein the first range corresponds to a firstequation of the plurality of PLA equations; obtain a plurality ofoperands associated with the first equation; compute, usingadder-subtractor circuitry, a result of the first equation based on theplurality of operands; and return, via an output register, an outputassociated with the logarithm operation, wherein the output is generatedbased at least in part on the result of the first equation.

In one example embodiment of an apparatus, the logarithm operation isassociated with an artificial neural network operation.

In one example embodiment of an apparatus: the input comprises afloating-point number, wherein the floating-point number comprises anexponent and a mantissa; and the output comprises a fixed-point number,wherein the fixed-point number comprises an integer and a fraction.

In one example embodiment of an apparatus, the plurality of operandscomprises the mantissa and one or more fraction operands, wherein theone or more fraction operands each comprise a denominator that comprisesa power of two.

In one example embodiment of an apparatus, the log circuit furthercomprises one or more shift circuits to generate the one or morefraction operands.

In one example embodiment of an apparatus, the log circuit furthercomprises a subtractor circuit to subtract a bias from the exponent ofthe floating-point number to generate an unbiased exponent.

In one example embodiment of an apparatus, the circuitry to return, viathe output register, the output associated with the logarithm operationis further to: generate the integer of the fixed-point number based onthe unbiased exponent; and generate the fraction of the fixed-pointnumber based on the result of the first equation.

In one example embodiment of an apparatus, wherein the log circuitfurther comprises one or more multiplexers to select the plurality ofoperands associated with the first equation.

In one example embodiment of an apparatus, wherein the adder-subtractorcircuitry is to perform one or more addition or subtraction operationson the plurality of operands.

In one example embodiment of an apparatus, the apparatus furthercomprises an antilog circuit, wherein the antilog circuit comprisescircuitry to: identify a second input associated with an antilogarithmoperation, wherein the antilogarithm operation is to be performed by theantilog circuit using piecewise linear approximation; identify a secondrange that the second input falls within, wherein the second range isidentified from a second plurality of ranges associated with a secondplurality of piecewise linear approximation (PLA) equations for theantilogarithm operation, and wherein the second range corresponds to asecond equation of the second plurality of PLA equations; compute asecond result of the second equation based on a second plurality ofoperands associated with the second equation; and generate a secondoutput associated with the antilogarithm operation, wherein the secondoutput is generated based at least in part on the second result of thesecond equation.

In one example embodiment of an apparatus, the apparatus furthercomprises an activation function circuit, wherein the activationfunction circuit comprises the log circuit and the antilog circuit, andwherein the activation function circuit further comprises circuitry to:receive an instruction to perform an activation function selected from aplurality of available activation functions, wherein the activationfunction comprises one or more multiplication or division operations;perform the one or more multiplication or division operations using oneor more logarithm operations and one or more antilogarithm operations,wherein the one or more logarithm operations are performed using the logcircuit and the one or more antilogarithm operations are performed usingthe antilog circuit; and generate an activation output associated withthe activation function, wherein the activation output is generatedbased at least in part on one or more results of the one or moremultiplication or division operations.

In one example embodiment of an apparatus: the activation functionfurther comprises one or more exponent operations; and the activationfunction circuit further comprises an exponent circuit to perform theone or more exponent operations using piecewise linear approximation.

One or more embodiments may include a system, comprising: a memory tostore information associated with an application; a processor to executeone or more instructions associated with the application; and anactivation function circuit to perform a plurality of activationfunctions, wherein the activation function circuit comprises circuitryto: receive an instruction to perform an activation function associatedwith the application, wherein the activation function is selected fromthe plurality of activation functions, and wherein the activationfunction comprises one or more multiplication or division operations;perform the one or more multiplication or division operations using oneor more log operations and one or more antilog operations, wherein theone or more log operations are performed by a log circuit usingpiecewise linear approximation, and wherein the one or more antilogoperations are performed by an antilog circuit using piecewise linearapproximation; and generate an output associated with the activationfunction, wherein the output is generated based at least in part on oneor more results of the one or more multiplication or divisionoperations.

In one example embodiment of a system, the application comprises anartificial neural network, and wherein the activation function isassociated with an operation of the artificial neural network.

In one example embodiment of a system, the circuitry to perform the oneor more multiplication or division operations using the one or more logoperations and the one or more antilog operations is further to: performone or more logarithm base 2 operations on one or more operandsassociated with the one or more multiplication or division operations,wherein the one or more logarithm base 2 operations are performed usingpiecewise linear approximation; perform one or more addition orsubtraction operations on one or more results of the one or morelogarithm base 2 operations; and perform one or more antilogarithm base2 operations on one or more results of the one or more addition orsubtraction operations, wherein the one or more antilogarithm base 2operations are performed using piecewise linear approximation.

In one example embodiment of a system: the activation function furthercomprises one or more exponent operations; and the activation functioncircuit further comprises circuitry to perform the one or more exponentoperations using piecewise linear approximation.

In one example embodiment of a system: the one or more exponentoperations each comprise a base of 2; and the circuitry to perform theone or more exponent operations using piecewise linear approximation isfurther to perform the one or more exponent operations using one or moreantilogarithm base 2 operations, wherein the one or more antilogarithmbase 2 operations are performed using piecewise linear approximation.

In one example embodiment of a system, the plurality of activationfunctions comprises: a sigmoid function; a hyperbolic tangent function;a swish function; and a rectified linear unit function.

In one example embodiment of a system: at least one of the sigmoidfunction, the hyperbolic tangent function, or the swish function isdefined using one or more exponent operations that exclusively comprisea base of 2; and the activation function circuit further comprisescircuitry to perform the one or more exponent operations using one ormore antilogarithm base 2 operations, wherein the one or moreantilogarithm base 2 operations are performed using piecewise linearapproximation.

One or more embodiments may include at least one machine accessiblestorage medium having instructions stored thereon, wherein theinstructions, when executed on a machine, cause the machine to: receive,by an activation function circuit, an instruction to perform anactivation function selected from a plurality of available activationfunctions, wherein the activation function comprises one or moremultiplication or division operations; perform the one or moremultiplication or division operations using one or more log operationsand one or more antilog operations, wherein the one or more logoperations and the one or more antilog operations are performed usingpiecewise linear approximation; and generate an output associated withthe activation function, wherein the output is generated based at leastin part on one or more results of the one or more multiplication ordivision operations.

In one example embodiment of a storage medium, the instructions thatcause the machine to perform the one or more multiplication or divisionoperations using the one or more log operations and the one or moreantilog operations further cause the machine to: perform one or morelogarithm base 2 operations on one or more operands associated with theone or more multiplication or division operations, wherein the one ormore logarithm base 2 operations are performed using piecewise linearapproximation; perform one or more addition or subtraction operations onone or more results of the one or more logarithm base 2 operations; andperform one or more antilogarithm base 2 operations on one or moreresults of the one or more addition or subtraction operations, whereinthe one or more antilogarithm base 2 operations are performed usingpiecewise linear approximation.

In one example embodiment of a storage medium: the activation functionfurther comprises one or more exponent operations; and the instructionsfurther cause the machine to perform the one or more exponent operationsusing piecewise linear approximation.

In one example embodiment of a storage medium: at least one activationfunction of the plurality of available activation functions is definedusing one or more exponent operations that exclusively comprise a baseof 2; and the instructions further cause the machine to perform the oneor more exponent operations using one or more antilogarithm base 2operations, wherein the one or more antilogarithm base 2 operations areperformed using piecewise linear approximation.

One or more embodiments may include a method, comprising: receiving, byan activation function circuit, an instruction to perform an activationfunction selected from a plurality of available activation functions,wherein the activation function comprises one or more multiplication ordivision operations; performing the one or more multiplication ordivision operations using one or more log operations and one or moreantilog operations, wherein the one or more log operations and the oneor more antilog operations are performed using piecewise linearapproximation; and generating an output associated with the activationfunction, wherein the output is generated based at least in part on oneor more results of the one or more multiplication or divisionoperations.

In one example embodiment of a method, the method further comprisesperforming one or more logarithm base 2 operations on one or moreoperands associated with the one or more multiplication or divisionoperations, wherein the one or more logarithm base 2 operations areperformed using piecewise linear approximation; performing one or moreaddition or subtraction operations on one or more results of the one ormore logarithm base 2 operations; and performing one or moreantilogarithm base 2 operations on one or more results of the one ormore addition or subtraction operations, wherein the one or moreantilogarithm base 2 operations are performed using piecewise linearapproximation.

What is claimed is:
 1. An activation function circuit, comprising:decode circuitry to decode a first instruction to perform a firstactivation function, wherein the first activation function is one of aplurality of activation functions implemented on the activation functioncircuit, and wherein the first activation function includes an exponentoperation and a division operation; exponent circuitry to perform theexponent operation using piecewise linear approximation; log circuitryto perform logarithm operations on a numerator and a denominator of thedivision operation using piecewise linear approximation; subtractorcircuitry to perform a subtraction operation on results of the logarithmoperations; antilog circuitry to perform an antilogarithm operation on aresult of the subtraction operation using piecewise linearapproximation; and output circuitry to output a result of the firstactivation function based on a result of the antilogarithm operation. 2.The activation function circuit of claim 1, wherein: the firstactivation function further includes a multiplication operation; the logcircuitry is further to perform logarithm operations on operands of themultiplication operation using piecewise linear approximation; theactivation function circuit further comprises adder circuitry to performan addition operation on results of the logarithm operations on theoperands of the multiplication operation; and the antilog circuitry isfurther to perform an antilogarithm operation on a result of theaddition operation using piecewise linear approximation, wherein aresult of the antilogarithm operation is a result of the multiplicationoperation.
 3. The activation function circuit of claim 1, wherein: theexponent operation has a base of 2; and the exponent circuitry toperform the exponent operation using piecewise linear approximation isfurther to perform the exponent operation using an antilogarithm base 2operation, wherein the antilogarithm base 2 operation is performed usingpiecewise linear approximation.
 4. The activation function circuit ofclaim 1, wherein the first activation function is: a sigmoid function; ahyperbolic tangent function; or a swish function.
 5. The activationfunction circuit of claim 1, wherein the plurality of activationfunctions include: a sigmoid function; a hyperbolic tangent function; aswish function; and a rectified linear unit function.
 6. The activationfunction circuit of claim 5, wherein: at least one of the sigmoidfunction, the hyperbolic tangent function, or the swish function isdefined using one or more exponent operations that exclusively have abase of 2, wherein the one or more exponent operations include theexponent operation; and the exponent circuitry to perform the exponentoperation using piecewise linear approximation is further to perform theone or more exponent operations using one or more antilogarithm base 2operations, wherein the one or more antilogarithm base 2 operations areperformed using piecewise linear approximation.
 7. The activationfunction circuit of claim 1, wherein the first instruction includes anopcode identifying the first activation function from the plurality ofactivation functions implemented on the activation function circuit. 8.The activation function circuit of claim 1, wherein the plurality ofactivation functions are associated with one or more artificial neuralnetworks.
 9. At least one non-transitory machine-accessible storagemedium having instructions stored thereon, wherein the instructions,when implemented or executed on processing circuitry comprising exponentcircuitry, log circuitry, antilog circuitry, and subtractor circuitry,cause the processing circuitry to: receive a first instruction toperform a first activation function, wherein the first activationfunction is one of a plurality of activation functions implemented onthe processing circuitry, and wherein the first activation functionincludes an exponent operation and a division operation; perform, usingthe exponent circuitry, the exponent operation using piecewise linearapproximation; perform, using the log circuitry, logarithm operations ona numerator and a denominator of the division operation using piecewiselinear approximation; perform, using the subtractor circuitry, asubtraction operation on results of the logarithm operations; perform,using the antilog circuitry, an antilogarithm operation on a result ofthe subtraction operation using piecewise linear approximation; andoutput a result of the first activation function based on a result ofthe antilogarithm operation.
 10. The storage medium of claim 9, wherein:the first activation function further includes a multiplicationoperation; the processing circuitry further comprises adder circuitry;and the instructions further cause the processing circuitry to: perform,using the log circuitry, logarithm operations on operands of themultiplication operation using piecewise linear approximation; perform,using the adder circuitry, an addition operation on results of thelogarithm operations on the operands of the multiplication operation;perform, using the antilog circuitry, an antilogarithm operation on aresult of the addition operation using piecewise linear approximation;and return a result of the multiplication operation based on a result ofthe antilogarithm operation on the result of the addition operation. 11.The storage medium of claim 9, wherein: the exponent operation has abase of 2; and the instructions that cause the processing circuitry toperform, using the exponent circuitry, the exponent operation usingpiecewise linear approximation further cause the processing circuitryto: perform, using the exponent circuitry, the exponent operation usingan antilogarithm base 2 operation, wherein the antilogarithm base 2operation is performed using piecewise linear approximation.
 12. Thestorage medium of claim 9, wherein: the first activation function isdefined using one or more exponent operations that exclusively have abase of 2, wherein the one or more exponent operations include theexponent operation; and the instructions that cause the processingcircuitry to perform, using the exponent circuitry, the exponentoperation using piecewise linear approximation further cause theprocessing circuitry to: perform, using the exponent circuitry, the oneor more exponent operations using one or more antilogarithm base 2operations, wherein the one or more antilogarithm base 2 operations areperformed using piecewise linear approximation.
 13. The storage mediumof claim 9, wherein the first activation function is: a sigmoidfunction; a hyperbolic tangent function; or a swish function.
 14. Thestorage medium of claim 9, wherein the plurality of activation functionsinclude: a sigmoid function; a hyperbolic tangent function; a swishfunction; and a rectified linear unit function.
 15. The storage mediumof claim 9, wherein the plurality of activation functions are associatedwith one or more artificial neural networks.
 16. A system, comprising: aprocessor; and an activation function circuit, comprising: decodecircuitry to decode a first instruction to perform a first activationfunction, wherein the first activation function is one of a plurality ofactivation functions implemented on the activation function circuit, andwherein the first activation function includes an exponent operation anda division operation; exponent circuitry to perform the exponentoperation using piecewise linear approximation; log circuitry to performlogarithm operations on a numerator and a denominator of the divisionoperation using piecewise linear approximation; subtractor circuitry toperform a subtraction operation on results of the logarithm operations;antilog circuitry to perform an antilogarithm operation on a result ofthe subtraction operation using piecewise linear approximation; andoutput circuitry to output a result of the first activation functionbased on a result of the antilogarithm operation.
 17. The system ofclaim 16, wherein: the first activation function further includes amultiplication operation; the log circuitry is further to performlogarithm operations on operands of the multiplication operation usingpiecewise linear approximation; the activation function circuit furthercomprises adder circuitry to perform an addition operation on results ofthe logarithm operations on the operands of the multiplicationoperation; and the antilog circuitry is further to perform anantilogarithm operation on a result of the addition operation usingpiecewise linear approximation, wherein a result of the antilogarithmoperation is a result of the multiplication operation.
 18. The system ofclaim 16, wherein: the exponent operation has a base of 2; and theexponent circuitry to perform the exponent operation using piecewiselinear approximation is further to perform the exponent operation usingan antilogarithm base 2 operation, wherein the antilogarithm base 2operation is performed using piecewise linear approximation.
 19. Thesystem of claim 16, wherein the first activation function is: a sigmoidfunction; a hyperbolic tangent function; or a swish function.
 20. Thesystem of claim 16, wherein the plurality of activation functionsinclude: a sigmoid function; a hyperbolic tangent function; a swishfunction; and a rectified linear unit function.
 21. The system of claim20, wherein: at least one of the sigmoid function, the hyperbolictangent function, or the swish function is defined using one or moreexponent operations that exclusively have a base of 2, wherein the oneor more exponent operations include the exponent operation; and theexponent circuitry to perform the exponent operation using piecewiselinear approximation is further to perform the one or more exponentoperations using one or more antilogarithm base 2 operations, whereinthe one or more antilogarithm base 2 operations are performed usingpiecewise linear approximation.
 22. The system of claim 16, wherein theplurality of activation functions are associated with one or moreartificial neural networks.